Plugin Directory

Changeset 2205471


Ignore:
Timestamp:
12/03/2019 07:08:14 PM (5 years ago)
Author:
jessehorne
Message:

added 0.4 tag; notice displays upon plugin activation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • clear-opcache/trunk/clear_op_cache_plugin.php

    r2196791 r2205471  
    8484}
    8585add_filter('upgrader_pre_install', 'bc_cocp_clear_caches', 10, 2);
     86add_filter('upgrader_process_complete', 'bc_cocp_clear_caches', 10, 2);
    8687
    8788function bc_cocp_add_flush_opcache_button($admin_bar){
     
    115116    if ($enabled) {
    116117        bc_cocp_clear_caches();
    117         wp_redirect("/wp-admin?opcache_cleared=true");
    118     } else {
    119         wp_redirect("/wp-admin?opcache_cleared=false");
     118        // wp_redirect("/wp-admin?opcache_cleared=true");
     119        $location = add_query_arg('opcache_cleared', 'true', $_SERVER['HTTP_REFERER']);
     120    wp_safe_redirect($location);
     121    } else {
     122        // wp_redirect("/wp-admin?opcache_cleared=false");
     123        $location = add_query_arg('opcache_cleared', 'false', $_SERVER['HTTP_REFERER']);
     124    wp_safe_redirect($location);
    120125    }
    121126}
     
    203208    <?php
    204209}
    205 ?>
     210
     211function bc_cocp_plugin_activation() {
     212  update_option('bc_cocp_plugin_activated', true);
     213  update_option('bc_cocp_plugin_notice_shown', false);
     214}
     215register_activation_hook(__FILE__, 'bc_cocp_plugin_activation');
     216
     217function bc_cocp_plugin_deactivation() {
     218  update_option('bc_cocp_plugin_activated', true);
     219}
     220register_deactivation_hook(__FILE__, 'bc_cocp_plugin_deactivation');
     221
     222function bc_cocp_plugin_notices() {
     223  $shown = get_option('bc_cocp_plugin_notice_shown');
     224
     225  if (!$shown) {
     226    echo "<div class='updated'><h2>Clear OPcache is installed, and ready to go.</h2><p>You can now flush your OPcache with the <b>Flush OPcache</b> button above and view settings in the <i>Settings</i>><b>OPcache</b> page to the left.</p></div>";
     227    update_option('bc_cocp_plugin_notice_shown', true);
     228  }
     229}
     230add_action('admin_notices', 'bc_cocp_plugin_notices');
Note: See TracChangeset for help on using the changeset viewer.