Skip to content

Commit

Permalink
Merge pull request #1699 from publishpress/feature/#1681_Redirect_aft…
Browse files Browse the repository at this point in the history
…er_install

feature/#1681_Redirect_after_install
  • Loading branch information
olatechpro authored Jul 19, 2024
2 parents c7b69d1 + 9d97a66 commit 2f4c062
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/calendar/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
26 changes: 25 additions & 1 deletion publishpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
}

}
Expand Down Expand Up @@ -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');
Expand All @@ -1392,3 +1409,10 @@ function () use ($message) {
}
do_action('publishpress_planner_loaded');
}, -10);

register_activation_hook(
__FILE__,
function () {
update_option('pp_planner_activated', true);
}
);

0 comments on commit 2f4c062

Please sign in to comment.