-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 26c0562
Showing
16 changed files
with
670 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Manuel | ||
|
||
 | ||
 | ||
|
||
Manuel is a WordPress plugin that searches for and removes broken links and images in WordPress posts, and updates the modified dates of these posts. | ||
|
||
## Features | ||
|
||
- Searches for broken links and images in WordPress posts | ||
- Removes broken links and images | ||
- Updates the modified dates of affected posts | ||
- Provides an admin interface for viewing removed links and images | ||
|
||
## Installation | ||
|
||
1. Download the plugin as a .zip file | ||
2. Go to the WordPress admin dashboard | ||
3. Navigate to `Plugins` > `Add New` | ||
4. Click `Upload Plugin` and upload the .zip file | ||
5. Click `Install Now` | ||
6. Activate the plugin | ||
|
||
## Usage | ||
|
||
After activating the plugin, it will automatically run on a schedule and search for broken links and images in your WordPress posts. | ||
|
||
You can view the removed links and images by navigating to the plugin's admin interface. | ||
|
||
## License | ||
|
||
Manuel is licensed under the GPL-2.0+ License. See the [LICENSE](http://www.gnu.org/licenses/gpl-2.0.txt) file for more information. | ||
|
||
## Support | ||
|
||
For any questions or issues, please visit the [plugin's repository](https://github.com/Thelastpoet). | ||
|
||
## Author | ||
|
||
Ammanulah Emmanuel | ||
|
||
[https://github.com](https://github.com/Thelastpoet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
if ( ! class_exists( 'WP_List_Table' ) ) { | ||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); | ||
} | ||
|
||
class Manuel_Stats_List_Table extends WP_List_Table { | ||
|
||
public function __construct() { | ||
parent::__construct( array( | ||
'singular' => __( 'Stat', 'manuel' ), | ||
'plural' => __( 'Stats', 'manuel' ), | ||
'ajax' => false, | ||
) ); | ||
} | ||
|
||
public function get_columns() { | ||
return array( | ||
'post_id' => __( 'Post ID', 'manuel' ), | ||
'post_title' => __( 'Post Title', 'manuel' ), | ||
'original_link' => __( 'Original Link', 'manuel' ), | ||
'anchor_text' => __( 'Anchor Text', 'manuel' ), | ||
'actions' => __( 'Actions', 'manuel' ), | ||
); | ||
} | ||
|
||
public function column_default( $item, $column_name ) { | ||
switch ( $column_name ) { | ||
case 'post_id': | ||
case 'post_title': | ||
case 'original_link': | ||
case 'anchor_text': | ||
return $item[ $column_name ]; | ||
case 'actions': | ||
return sprintf( | ||
'<button class="button edit-link" data-post-id="%s" data-original-link="%s">%s</button>', | ||
$item['post_id'], | ||
$item['original_link'], | ||
__( 'Edit', 'manuel' ) | ||
); | ||
default: | ||
return print_r( $item, true ); | ||
} | ||
} | ||
|
||
public function prepare_items() { | ||
$columns = $this->get_columns(); | ||
$hidden = array(); | ||
$sortable = array(); | ||
$this->_column_headers = array( $columns, $hidden, $sortable ); | ||
|
||
$manuel_settings = new Manuel_Settings( '1.0' ); | ||
$this->items = $manuel_settings->get_manuel_cron()->get_stats(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
// Check if the user has the necessary permissions | ||
if ( ! current_user_can( 'manage_options' ) ) { | ||
return; | ||
} | ||
?> | ||
|
||
<div class="wrap"> | ||
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> | ||
|
||
<form method="post" action="options.php"> | ||
<?php | ||
// Output security fields for the registered setting | ||
settings_fields( 'manuel_settings' ); | ||
|
||
// Output the settings sections and fields | ||
do_settings_sections( 'manuel-settings' ); | ||
|
||
// Output the submit button | ||
submit_button(); | ||
?> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// Fetch statistics from the database. | ||
$manuel_settings = new Manuel_Settings( '1.0' ); | ||
$removed_images = $manuel_settings->get_manuel_cron()->get_images_stats(); | ||
?> | ||
|
||
<div class="wrap"> | ||
<h1><?php _e( 'Removed Images List', 'manuel' ); ?></h1> | ||
|
||
<table class="widefat"> | ||
<thead> | ||
<tr> | ||
<th><?php _e( 'Post ID', 'manuel' ); ?></th> | ||
<th><?php _e( 'Post Title', 'manuel' ); ?></th> | ||
<th><?php _e( 'Original Image', 'manuel' ); ?></th> | ||
<th><?php _e( 'Time Removed', 'manuel' ); ?></th> | ||
<th><?php _e( 'Actions', 'manuel' ); ?></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ( $removed_images as $stat ) : ?> | ||
<tr> | ||
<td><?php echo $stat['post_id']; ?></td> | ||
<td><?php echo $stat['post_title']; ?></td> | ||
<td><?php echo $stat['original_image']; ?></td> | ||
<td><?php echo $stat['time-removed']; ?></td> | ||
<td> | ||
<button class="button edit-image-stats" data-post-id="<?php echo $stat['post_id']; ?>" data-original-image="<?php echo $stat['original_image']; ?>"> | ||
<?php _e( 'Edit', 'manuel' ); ?> | ||
</button> | ||
</td> | ||
</tr> | ||
<?php endforeach; ?> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// Fetch statistics from the database. | ||
$manuel_settings = new Manuel_Settings( '1.0' ); | ||
$stats = $manuel_settings->get_manuel_cron()->get_stats(); | ||
?> | ||
|
||
<div class="wrap"> | ||
<h1><?php _e( 'Manuel Stats', 'manuel' ); ?></h1> | ||
|
||
<table class="widefat"> | ||
<thead> | ||
<tr> | ||
<th><?php _e( 'Post ID', 'manuel' ); ?></th> | ||
<th><?php _e( 'Post Title', 'manuel' ); ?></th> | ||
<th><?php _e( 'Original Link', 'manuel' ); ?></th> | ||
<th><?php _e( 'Anchor Text', 'manuel' ); ?></th> | ||
<th><?php _e( 'Actions', 'manuel' ); ?></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ( $stats as $stat ) : ?> | ||
<tr> | ||
<td><?php echo $stat['post_id']; ?></td> | ||
<td><?php echo $stat['post_title']; ?></td> | ||
<td><?php echo $stat['original_link']; ?></td> | ||
<td><?php echo $stat['anchor_text']; ?></td> | ||
<td> | ||
<button class="button edit-link" data-post-id="<?php echo $stat['post_id']; ?>" data-original-link="<?php echo $stat['original_link']; ?>"> | ||
<?php _e( 'Edit', 'manuel' ); ?> | ||
</button> | ||
</td> | ||
</tr> | ||
<?php endforeach; ?> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* all the css here */ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
jQuery(document).ready(function ($) { | ||
// Edit link click event. | ||
$('.edit-link').on('click', function () { | ||
var postId = $(this).data('post-id'); | ||
var originalLink = $(this).data('original-link'); | ||
|
||
// Display a prompt to input the new URL | ||
var newLink = prompt('Enter the new URL for the broken link:', originalLink); | ||
if (newLink !== null && newLink !== originalLink) { | ||
// Call the AJAX function to update the post with the new URL. | ||
$.ajax({ | ||
url: ajaxurl, | ||
type: 'POST', | ||
data: { | ||
action: 'manuel_update_link', | ||
post_id: postId, | ||
original_link: originalLink, | ||
new_link: newLink, | ||
anchor_text: $(this).closest('tr').find('td:nth-child(4)').text(), | ||
time_removed: $(this).closest('tr').find('td:nth-child(5)').text(), | ||
nonce: manuelStats.nonce | ||
}, | ||
success: function (response) { | ||
if (response.success) { | ||
// Show a success message after the AJAX call is successful. | ||
alert('Link updated successfully'); | ||
} else { | ||
alert('Error: ' + response.data); | ||
} | ||
}, | ||
error: function () { | ||
alert('An error occurred while updating the link.'); | ||
} | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
require_once MANUEL_PLUGIN_DIR . '/includes/class-manuel-cron.php'; | ||
|
||
class Manuel_Activator { | ||
public static function activate( $version ) { | ||
// Unschedule the existing cron event | ||
$timestamp = wp_next_scheduled( 'manuel_cron_event' ); | ||
if ( $timestamp ) { | ||
wp_unschedule_event( $timestamp, 'manuel_cron_event' ); | ||
} | ||
|
||
// Schedule the new cron job | ||
$cron_interval = get_option( 'manuel_cron_interval', 'manuel_five_times_daily' ); | ||
wp_schedule_event( time(), $cron_interval, 'manuel_cron_event' ); | ||
|
||
// Create Manuel db table here | ||
$manuel_cron = new Manuel_Cron( $version ); | ||
$manuel_cron->manuel_db(); | ||
} | ||
|
||
} |
Oops, something went wrong.