Skip to content

Commit

Permalink
fix cron triggering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cagrimmett committed Dec 30, 2022
1 parent f0f78e2 commit 0cb28d7
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions feedbin-stars-to-indie-likes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
* Plugin Name: Feedbin Stars to Indie Likes
* Plugin URI: https://github.com/cagrimmett/feedbin-stars-to-indie-likes
* Description: Takes starred posts from Feedbin and turns them into Indie Likes.
* Version: 0.0.1
* Version: 0.0.2
* Author: cagrimmett
* Author URI: https://cagrimmett.com
* Text Domain: fs2il
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/

require_once ABSPATH . 'wp-admin/includes/plugin.php';

function fs2il_activate() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
Expand Down Expand Up @@ -41,20 +42,15 @@ function fs2il_activate() {
'fs2il_settings',
'fs2il_date'
);
// schedule cron hook
if ( ! wp_next_scheduled( 'fs2il_hook' ) ) {
wp_schedule_event( time(), 'hourly', 'fs2il_hook' );
}
}
register_activation_hook( __FILE__, 'fs2il_activate' );

// schedule a cron job to run every 5 minutes
function fs2il_schedule() {
wp_schedule_event( time(), 'hourly', 'fs2il_fetch_new_likes' );
}

register_activation_hook( __FILE__, 'fs2il_schedule' );
// hook that function onto our scheduled event
add_action( 'fs2il_fetch_new_likes', 'fs2il_convert_stars_to_likes' );

function fs2il_deactivate() {
wp_clear_scheduled_hook( 'fs2il_fetch_new_likes' );
wp_clear_scheduled_hook( 'fs2il_hook' );
}
register_deactivation_hook( __FILE__, 'fs2il_deactivate' );

Expand Down Expand Up @@ -156,6 +152,9 @@ function( $feedbin_post ) use ( $existing_posts ) {
}
}

// hook that function onto our scheduled event
add_action( 'fs2il_hook', 'fs2il_convert_stars_to_likes' );

function fs2il_options_page() {
add_submenu_page(
'tools.php', // Parent page slug
Expand Down Expand Up @@ -262,8 +261,8 @@ function fs2il_settings_page() {
}

function fs2il_settings_link( $links ) {
$settings_link = '<a href="' . admin_url( 'tools.php?page=fs2il-settings' ) . '">Settings</a>';
array_unshift( $links, $settings_link );
return $links;
$settings_link = '<a href="' . admin_url( 'tools.php?page=fs2il-settings' ) . '">Settings</a>';
array_unshift( $links, $settings_link );
return $links;
}
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'fs2il_settings_link' );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'fs2il_settings_link' );

0 comments on commit 0cb28d7

Please sign in to comment.