diff --git a/modules/calendar/calendar.php b/modules/calendar/calendar.php index 2a983d58..680ee54f 100644 --- a/modules/calendar/calendar.php +++ b/modules/calendar/calendar.php @@ -3305,7 +3305,7 @@ public function getCalendarDataForMultipleWeeks($args = [], $context = 'dashboar if (isset($this->module->options->sort_by)) { add_filter('posts_orderby', [$this, 'filterPostsOrderBy'], 10); } -write_log($args); + $post_results = new WP_Query($args); $posts = []; diff --git a/publishpress.php b/publishpress.php index 417b97f0..6a67ab70 100644 --- a/publishpress.php +++ b/publishpress.php @@ -173,6 +173,8 @@ private function setup_actions() add_filter('debug_information', [$this, 'filterDebugInformation']); add_filter('cme_plugin_capabilities', [$this, 'filterCapabilities'], 11); + // Redirect on plugin activation + add_action('admin_init', [$this, 'redirect_on_activate'], 2000); } /** @@ -1291,6 +1293,20 @@ public function getCorePostStatuses() { 'position' => 3, ], ]; + } + + /** + * Redirect user on plugin activation + * + * @return void + */ + public function redirect_on_activate() + { + if (get_option('pp_planner_activated')) { + delete_option('pp_planner_activated'); + wp_safe_redirect(admin_url("admin.php?page=pp-calendar")); + exit; + } } } @@ -1369,7 +1385,8 @@ function PublishPress() if (! defined('PUBLISHPRESS_HOOKS_REGISTERED')) { PublishPress(); add_action('init', 'publishPressRegisterImprovedNotificationsPostTypes'); - register_activation_hook(__FILE__, ['publishpress', 'activation_hook']); + // currently not working inside plugins_loaded + // register_activation_hook(__FILE__, ['publishpress', 'activation_hook']); define('PUBLISHPRESS_HOOKS_REGISTERED', 1); } else { $message = __('PublishPress Planner tried to load multiple times. Please, deactivate and remove other instances of PublishPress, specially if you are using PublishPress Pro.', 'publishpress'); @@ -1392,3 +1409,10 @@ function () use ($message) { } do_action('publishpress_planner_loaded'); }, -10); + +register_activation_hook( + __FILE__, + function () { + update_option('pp_planner_activated', true); + } +); \ No newline at end of file