Plugin Directory

Changeset 1906488


Ignore:
Timestamp:
07/09/2018 02:08:01 PM (8 years ago)
Author:
devavi
Message:

Fix issues

Location:
purge-varnish
Files:
26 added
5 edited

Legend:

Unmodified
Added
Removed
  • purge-varnish/trunk/class_purge_varnish.php

    r1724944 r1906488  
    4444        if (current_user_can('manage_options')) {
    4545            add_submenu_page('purge-varnish-settings', 'Terminal', 'Terminal', 'manage_options', 'purge-varnish-settings', array(
    46              $this, 'purge_varnish_page_file_path'));
     46                $this, 'purge_varnish_page_file_path'));
    4747            add_submenu_page('purge-varnish-settings', 'Purge all', 'Purge all', 'manage_options', 'purge-varnish-all', array(
    48               $this, 'purge_varnish_page_file_path'));
     48                $this, 'purge_varnish_page_file_path'));
    4949
    5050            add_submenu_page('purge-varnish-settings', 'Expire', 'Expire', 'manage_options', 'purge-varnish-expire', array(
    51               $this, 'purge_varnish_page_file_path'));
     51                $this, 'purge_varnish_page_file_path'));
    5252        }
    5353
    5454        if (current_user_can('edit_posts')) {
    5555            add_submenu_page('purge-varnish-settings', 'Purge URLs', 'Purge URLs', 'edit_posts', 'purge-varnish-urls', array(
    56               $this, 'purge_varnish_page_file_path'));
     56                $this, 'purge_varnish_page_file_path'));
    5757        }
    5858    }
     
    165165                $result = socket_write($client, "$command\n");
    166166                if ($status = $this->purge_varnish_execute_command($client, $command)) {
    167                     $logdata .= $status;
    168167                    $ret[$terminal][$command] = $status;
    169168                }
     
    216215                error_log('Socket error: ' . socket_strerror($error), 0);
    217216                return array(
    218                   'code' => $error,
    219                   'msg' => socket_strerror($error),
     217                    'code' => $error,
     218                    'msg' => socket_strerror($error),
    220219                );
    221220            }
     
    224223
    225224        $status = array(
    226           'code' => substr($header, 0, 3),
    227           'msg' => socket_read($client, $msg_len, PHP_BINARY_READ),
     225            'code' => substr($header, 0, 3),
     226            'msg' => socket_read($client, $msg_len, PHP_BINARY_READ),
    228227        );
    229228
     
    273272            $message['error']['varnish_socket_timeout'] = esc_html('Varnish connection timeout must be a positive number.');
    274273        }
    275        
     274
    276275        $msg = '';
    277276        if (isset($message['error']) && count($message['error'])) {
     
    483482                if (count($custom_urls)) {
    484483                    foreach ($custom_urls as $url) {
    485                         $command = $this->purge_varnish_get_command($url);
    486                         $this->purge_varnish_terminal_run(array($command));
     484                        $url = trim($url);
     485                        if (!empty($url)) {
     486                            $command = $this->purge_varnish_get_command($url);
     487                            $this->purge_varnish_terminal_run(array($command));
     488                        }
    487489                    }
    488490                }
     
    556558            $expire = unserialize($purge_varnish_expire);
    557559            if (is_array($expire)) {
     560                $uploads_path = wp_upload_dir();
    558561                foreach ($expire as $page) {
    559562                    switch ($page) {
     
    609612        }
    610613
    611         if (($new_status <> $old_status) && ($new_status == 'approved' || $old_status == 'approved')) {
     614        if (($new_status <> $old_status) && ($new_status == 'approved')) {
    612615            $comment_post_id = $comment->comment_post_ID;
    613616            $post = get_post($comment_post_id);
     
    697700
    698701    /*
    699      * Callback to purge various type of varnish objects on comment edited.
    700      */
    701 
    702     function purge_varnish_comment_post_trigger($ID) {
    703         $comment = get_comment($ID);
    704 
    705         if (!is_object($comment)) {
     702     * Callback to purge publish post object whenever comment is posted
     703     */
     704
     705    function purge_varnish_comment_insert_trigger($comment_id, $comment_object) {
     706        // Cause with wp_update_nav_menu
     707        if (is_object($comment_object)) {
     708            $post_id = $comment_object->comment_post_ID;
     709            $post = get_post($post_id);
     710
     711            // Halt exection if not have post object
     712            $this->purge_varnish_is_post_object($post);
     713            if ($post->post_status == 'publish') {
     714                $this->purge_varnish_trigger_post_expire($post);
     715            }
     716        } else {
    706717            return;
    707718        }
    708 
    709         $post_id = $comment->comment_post_ID;
    710         $post = get_post($ID);
    711 
    712         if (is_object($comment) && ($comment->comment_approved <> 1 || $post->post_status <> 'publish')) {
     719    }
     720
     721    /*
     722     * Callback to purge publish post object whenever comment is posted
     723     */
     724
     725    function purge_varnish_comment_edit_trigger($comment_id, $comment_object) {
     726        // Cause with wp_update_nav_menu
     727        if (is_object($comment_object)) {
     728            $post_id = $comment_object->comment_post_ID;
     729            $post = get_post($post_id);
     730
     731            // Halt exection if not have post object
     732            $this->purge_varnish_is_post_object($post);
     733            if ($post->post_status == 'publish') {
     734                $this->purge_varnish_trigger_post_expire($post);
     735            }
     736        } else {
    713737            return;
    714738        }
    715         // Call to purge
    716         $this->purge_varnish_trigger_comment_expire($post);
    717739    }
    718740
     
    800822    function purge_varnish_default_actions() {
    801823        return array(
    802           'post_insert_update' => 'post_updated',
    803           'post_status' => 'transition_post_status',
    804           'post_trash' => 'wp_trash_post',
    805           'comment_insert_update' => 'comment_post',
    806           'navmenu_insert_update' => 'wp_update_nav_menu',
    807           'theme_switch' => 'after_switch_theme',
     824            'post_insert_update' => 'post_updated',
     825            'post_status' => 'transition_post_status',
     826            'post_trash' => 'wp_trash_post',
     827            'comment_insert' => 'wp_insert_comment',
     828            'comment_update' => 'edit_comment',
     829            'navmenu_insert_update' => 'wp_update_nav_menu',
     830            'theme_switch' => 'after_switch_theme',
    808831        );
    809832    }
     
    816839        $default_actions = $this->purge_varnish_default_actions();
    817840        $additional_actions = array(
    818           'comment_status_changed' => 'transition_comment_status',
     841            'comment_status_changed' => 'transition_comment_status',
    819842        );
    820843        $actions = $default_actions + $additional_actions;
     
    834857    function purge_varnish_default_tiggers() {
    835858        return array(
    836           'post_front_page' => 'front_page',
    837           'post_custom_url' => 'custom_url',
    838           'post_post_item' => 'post_item',
    839           'post_category_page' => 'category_page',
    840           'comment_front_page' => 'front_page',
    841           'comment_custom_url' => 'custom_url',
    842           'navmenu_front_page' => 'front_page',
    843           'navmenu_custom_url' => 'custom_url',
    844           'wp_theme_front_page' => 'front_page',
    845           'wp_theme_custom_url' => 'custom_url',
     859            'post_front_page' => 'front_page',
     860            'post_custom_url' => 'custom_url',
     861            'post_post_item' => 'post_item',
     862            'post_category_page' => 'category_page',
     863            'comment_front_page' => 'front_page',
     864            'comment_custom_url' => 'custom_url',
     865            'navmenu_front_page' => 'front_page',
     866            'navmenu_custom_url' => 'custom_url',
     867            'wp_theme_front_page' => 'front_page',
     868            'wp_theme_custom_url' => 'custom_url',
    846869        );
    847870    }
     
    854877        $default_tiggers = $this->purge_varnish_default_tiggers();
    855878        $additional_tiggers = array(
    856           'comment_post_item' => 'post_item',
    857           'navmenu_menu_link' => 'post_item',
    858           'wp_theme_purge_all' => 'purge_all',
    859           'post_custom_urls' => '?',
    860           'comment_custom_urls' => '?',
    861           'navmenu_custom_urls' => '?',
    862           'wp_theme_custom_urls' => '?',
     879            'comment_post_item' => 'post_item',
     880            'navmenu_menu_link' => 'menu_item',
     881            'wp_theme_purge_all' => 'purge_all',
     882            'post_custom_urls' => '?',
     883            'comment_custom_urls' => '?',
     884            'navmenu_custom_urls' => '?',
     885            'wp_theme_custom_urls' => '?',
    863886        );
    864887        $tiggers = $default_tiggers + $additional_tiggers;
     
    939962if (!empty($purge_varnish_action)) {
    940963    $actions = unserialize($purge_varnish_action);
    941     if (is_array($actions)) {
     964    if (is_array($actions)) {       
    942965        foreach ($actions as $action) {
    943966            switch ($action) {
     
    957980                    break;
    958981
    959                 case 'comment_post':
    960                     add_action($action, array($purge_varnish, 'purge_varnish_comment_post_trigger'));
     982                case 'wp_insert_comment':
     983                    add_action($action, array($purge_varnish, 'purge_varnish_comment_insert_trigger'), 10, 3);
     984                    break;
     985
     986                case 'edit_comment':
     987                    add_action($action, array($purge_varnish, 'purge_varnish_comment_edit_trigger'), 10, 3);
    961988                    break;
    962989
  • purge-varnish/trunk/css/purge_varnish.css

    r1624809 r1906488  
    11.purge_varnish
    22{
    3   width: 90%;
    4   padding-left: 2px;
     3    width: 98%;
     4    padding-left: 2px;
    55}
    66.purge_varnish table
    77{
    8   width: 80%;
     8    width: 98%;
    99}
    1010.purge_varnish .screen
    1111{
    12   background-color: #fff;
    13   padding-bottom: 30px;
     12    background-color: #fff;
     13    padding-bottom: 30px;
    1414}
    1515.purge_varnish h2
    1616{
    17   background-image: url("../images/purge16x16.png");
    18   background-position: left 8px center;
    19   background-repeat: no-repeat;
    20   margin: 15px 0 0;
    21   padding: 9px 0 9px 30px;
     17    background-image: url("../images/purge16x16.png");
     18    background-position: left 8px center;
     19    background-repeat: no-repeat;
     20    margin: 15px 0 0;
     21    padding: 9px 0 9px 30px;
    2222}
    2323.purge_varnish .screen .desc
    2424{
    25   padding-left: 23px;
    26   color: #777;
     25    padding-left: 23px;
     26    color: #777;
    2727}
    2828
    2929.terminal_desc
    3030{
    31   padding-top: 3px;
    32   color: #777;
     31    padding-top: 3px;
     32    color: #777;
    3333}
    3434
    3535.purge_varnish table th{
    36   text-align: right;
    37   padding-right: 20px;
     36    text-align: right;
     37    vertical-align: text-top;
    3838}
    3939.purge_varnish table td{
    40   text-align: left;
    41   padding-right: 20px;
     40    text-align: left;
     41    vertical-align: text-top;
    4242}
    4343
    4444.purge_varnish input[type=text], .purge_varnish select {
    45   width: 350px;
    46   border: 1px solid #0073AA;
    47   border-left: 4px solid #1d8ccc;
     45    width: 350px;
     46    border: 1px solid #0073AA;
     47    border-left: 4px solid #1d8ccc;
    4848}
    4949
    5050.purge_varnish input[type=checkbox]{
    51   border: 1px solid #0073AA;
    52   border-left: 4px solid #1d8ccc;
     51    border: 2px solid #0073AA;
     52/*    border-left: 4px solid #1d8ccc;*/
    5353}
    5454
    5555.purge_varnish code
    5656{
    57   border-left: 4px solid #1d8ccc;
    58   padding: 4px;
    59   font-size: 14px;
     57    border-left: 4px solid #1d8ccc;
     58    padding: 4px;
     59    font-size: 14px;
    6060}
    6161.purge_varnish input[type=submit] {
     
    7373    transition-timing-function: ease-in;
    7474}
    75 ul.tab {
    76   border-left: 5px solid #fff;
    77   border-right: 5px solid #fff;
    78   list-style-type: none;
    79   margin: 0;
    80   padding: 0;
    81   overflow: hidden;
    82   border-top: none;
    83   background-color: #f1f1f1;
     75ul.tab {   
     76    list-style-type: none;
     77    margin: 0;
     78    padding: 0;
     79    overflow: hidden;
     80    border-top: none;
     81    background-color: #f1f1f1;
    8482}
    8583
    8684/* Float the list items side by side */
    8785ul.tab li {
    88   float: left;
    89   border-right: #eee;
     86    float: left;
     87    border-right: #eee;
    9088}
    9189
    9290/* Style the links inside the list items */
    9391ul.tab li a {
    94   display: inline-block;
    95   color: black;
    96   text-align: center;
    97   padding: 14px 16px;
    98   text-decoration: none;
    99   transition: 0.3s;
    100   font-size: 17px;
     92    display: inline-block;
     93    color: black;
     94    text-align: center;
     95    padding: 10px 30px;
     96    text-decoration: none;
     97    transition: 0.3s;
     98    font-size: 17px;
    10199}
    102100
    103101/* Change background color of links on hover */
    104102ul.tab li a:hover {
    105   background-color: #ddd;
     103    background-color: #ddd;
    106104}
    107105
    108106/* Create an active/current tablink class */
    109107ul.tab li a:focus, .active {
    110   background-color: #ccc;
     108    background-color: #ccc;
    111109}
    112110
    113111/* Style the tab content */
    114112.tabcontent {
    115   border-style:none!important;;
    116   display: none;
    117   padding: 6px 12px;
    118   border: 1px solid #ccc;
    119   border-top: none;
     113    border-style:none!important;;
     114    display: none;
     115    padding: 6px 12px;
     116    border: 1px solid #ccc;
     117    border-top: none;
    120118}
    121119
    122120.tablinks{
    123   font-weight: bold;
    124   font-size: 20px;
     121    font-weight: bold;
     122    font-size: 20px;
    125123}
    126124#wpbody-content dd, li {
     
    129127.hide_custom_url {display: none;}
    130128.show_custom_url {display: block;}
     129
     130/*input[type="checkbox"][readonly] {
     131    pointer-events: none;
     132}*/
     133
     134
     135table.expiration tr td{
     136    border-bottom: 1px  solid #ccc;
     137    padding-bottom: 20px;
     138}
     139table.expiration tr td:first-child{
     140    background-color: #fbfbfb;
     141}
     142tr.expiration td{
     143    padding-top: 20px;
     144    background-color: #fbfbfb;
     145}
  • purge-varnish/trunk/includes/expire.php

    r1705528 r1906488  
    1313    if ($purge_varnish->purge_varnish_nonce('pvEsetting') == true) {
    1414        $post_actions = (array) $_POST['purge_varnish_action'];
     15
    1516        $sanitize_actions = $purge_varnish->purge_varnish_sanitize_actions($post_actions);
    1617        update_option('purge_varnish_action', serialize($sanitize_actions));
     
    2728$post_status = '';
    2829$post_trash = '';
    29 $comment_insert_update = '';
     30$comment_insert = '';
     31$comment_update = '';
    3032$comment_status_changed = '';
    3133$navmenu_insert_update = '';
     
    3638    $post_status = isset($action['post_status']) ? $action['post_status'] : '';
    3739    $post_trash = isset($action['post_trash']) ? $action['post_trash'] : '';
    38     $comment_insert_update = isset($action['comment_insert_update']) ? $action['comment_insert_update'] : '';
     40    $comment_insert = isset($action['comment_insert']) ? $action['comment_insert'] : '';
     41    $comment_update = isset($action['comment_update']) ? $action['comment_update'] : '';
    3942    $comment_status_changed = isset($action['comment_status_changed']) ? $action['comment_status_changed'] : '';
    4043    $navmenu_insert_update = isset($action['navmenu_insert_update']) ? $action['navmenu_insert_update'] : '';
     
    149152                                    <input type="checkbox" name="purge_varnish_expire[post_custom_url]" value="custom_url" <?php print $expire_post_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
    150153                                    <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span>
    151                                 <div class="custom_url <?php print $expire_post_custom_url_class; ?>"><b>Enter custom URLs </b>
     154                                <div class="custom_url <?php print $expire_post_custom_url_class; ?>">
    152155                                    <textarea rows="3" cols="70" name="purge_varnish_expire[post_custom_urls]" class="input_custom_urls"><?php print $expire_post_custom_urls; ?></textarea>
    153156                                    <div>
     
    157160                                        </tbody>
    158161                                        </table>
    159                                     </div>
    160 
    161                                     <div id="comment_expiration" class="tabcontent">
    162                                         <h3><?php esc_html_e('Comment expiration'); ?></h3>
    163                                         <table cellpadding="5">
    164                                             <tbody>
    165                                                 <tr>
    166                                                     <th width="20%"></th>
    167                                                     <td width="80%">
    168                                                         <b><?php esc_html_e('Comment actions') ?></b>
    169                                                         <p>
    170                                                             <input type="checkbox" name="purge_varnish_action[comment_insert_update]" value="comment_post" <?php
    171                                                             if ($comment_insert_update == 'comment_post') {
    172                                                                 print 'checked="checked"';
    173                                                             }
    174                                                             ?> /> <label><?php esc_html_e('Comment insert/update'); ?></label> <br /> <span class="desc"><?php esc_html_e('Trigger when approved comment is posted on approved post.'); ?></span><br />
    175 
    176                                                             <input type="checkbox" name="purge_varnish_action[comment_status_changed]" value="transition_comment_status" <?php
    177                                                             if ($comment_status_changed == 'transition_comment_status') {
    178                                                                 print 'checked="checked"';
    179                                                             }
    180                                                             ?> /> <label><?php esc_html_e('Comment status changed'); ?></label> <br /><span class="desc"><?php esc_html_e('Trigger when comment is approved/unapproved.'); ?></span><br />
    181 
    182                                                         </p>
    183                                                     </td>
    184                                                 </tr>
    185                                                 <tr>
    186                                                     <th> </th>
    187                                                     <td>
    188                                                         <b><?php esc_html_e('What URLs should be expired when comment action is triggered?'); ?></b>
    189                                                         <p>
    190                                                             <input type="checkbox" name="purge_varnish_expire[comment_front_page]" value="front_page" <?php
    191                                                             if ($expire_comment_front_page == 'front_page') {
    192                                                                 print 'checked="checked"';
    193                                                             }
    194                                                             ?> /> <label><?php esc_html_e('Front page'); ?></label> <br /><span class="desc"><?php esc_html_e('Expire url of the site front page'); ?></span><br />
    195                                                             <input type="checkbox" name="purge_varnish_expire[comment_post_item]" value="post_item" <?php
    196                                                             if ($expire_comment_post_item == 'post_item') {
    197                                                                 print 'checked="checked"';
    198                                                             }
    199                                                             ?> /> <label><?php esc_html_e('Post page'); ?></label> <br /> <span class="desc"><?php esc_html_e('Expire url of the expiring post/page'); ?></span><br />
    200 
    201                                                             <?php
    202                                                             $expire_comment_custom_url_class = 'hide_custom_url';
    203                                                             $expire_comment_checked = '';
    204                                                             if ($expire_comment_custom_url == 'custom_url') {
    205                                                                 $expire_comment_checked = 'checked="checked"';
    206                                                                 $expire_comment_custom_url_class = 'show_custom_url';
    207                                                             }
    208                                                             ?>
    209                                                             <input type="checkbox" name="purge_varnish_expire[comment_custom_url]" value="custom_url" <?php print $expire_comment_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
    210                                                             <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span><br />
    211                                                         <div class="custom_url <?php print $expire_comment_custom_url_class; ?>"><b>Enter custom URLs </b>
    212                                                             <textarea rows="3" cols="70" name="purge_varnish_expire[comment_custom_urls]" class="input_custom_urls"><?php print $expire_comment_custom_urls; ?></textarea>
    213                                                         </div>
    214                                                         </p>
    215                                                     </td>
    216                                                 </tr>
    217                                             </tbody>
    218                                         </table>
    219                                     </div>
    220 
    221                                     <div id="menu_expiration" class="tabcontent">
    222                                         <h3><?php esc_html_e('Menu links expiration'); ?></h3>
    223                                         <table cellpadding="5">
    224                                             <tbody>
    225                                                 <tr>
    226                                                     <th width="20%"></th>
    227                                                     <td width="80%">
    228                                                         <b><?php esc_html_e('Menu link actions') ?></b>
    229                                                         <p>
    230                                                             <input type="checkbox" name="purge_varnish_action[navmenu_insert_update]" value="wp_update_nav_menu" <?php
    231                                                             if ($navmenu_insert_update == 'wp_update_nav_menu') {
    232                                                                 print 'checked="checked"';
    233                                                             }
    234                                                             ?> /> <label><?php esc_html_e('Menu link insert/update/delete'); ?></label> <br /> <span class="desc"><?php esc_html_e('Trigger on menu save action.'); ?></span><br />
    235                                                         </p>
    236                                                     </td>
    237                                                 </tr>
    238                                                 <tr>
    239                                                     <th> </th>
    240                                                     <td>
    241                                                         <b><?php esc_html_e('What URLs should be expired when menu save action is triggered?') ?></b>
    242                                                         <p>
    243                                                             <input type="checkbox" name="purge_varnish_expire[navmenu_front_page]" value="front_page" <?php
    244                                                             if ($expire_navmenu_front_page == 'front_page') {
    245                                                                 print 'checked="checked"';
    246                                                             }
    247                                                             ?> /> <label><?php esc_html_e('Front page'); ?></label> <br /><span class="desc"><?php esc_html_e('Expire url of the site front page'); ?></span><br />
    248                                                             <input type="checkbox" name="purge_varnish_expire[navmenu_menu_link]" value="post_item" <?php
    249                                                             if ($expire_navmenu_link == 'post_item') {
    250                                                                 print 'checked="checked"';
    251                                                             }
    252                                                             ?> /> <label><?php esc_html_e('Menu links'); ?></label> <br /> <span class="desc"><?php esc_html_e('Expire url of menu links'); ?></span><br />
    253 
    254                                                             <?php
    255                                                             $expire_navmenu_custom_url_class = 'hide_custom_url';
    256                                                             $expire_navmenu_checked = '';
    257                                                             if ($expire_navmenu_custom_url == 'custom_url') {
    258                                                                 $expire_navmenu_checked = 'checked="checked"';
    259                                                                 $expire_navmenu_custom_url_class = 'show_custom_url';
    260                                                             }
    261                                                             ?>
    262                                                             <input type="checkbox" name="purge_varnish_expire[navmenu_custom_url]" value="custom_url" <?php print $expire_navmenu_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
    263                                                             <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span><br />
    264                                                         <div class="custom_url <?php print $expire_navmenu_custom_url_class; ?>"><b>Enter custom URLs </b>
    265                                                             <textarea rows="3" cols="70" name="purge_varnish_expire[navmenu_custom_urls]" class="input_custom_urls"><?php print $expire_navmenu_custom_urls; ?></textarea>
    266                                                         </div>
    267                                                         </p>
    268                                                     </td>
    269                                                 </tr>
    270                                             </tbody>
    271                                         </table>
    272                                     </div>
    273 
    274                                     <div id="switch_theme" class="tabcontent">
    275                                         <h3><?php esc_html_e('Switch theme expiration'); ?></h3>
    276                                         <table cellpadding="5">
    277                                             <tbody>
    278                                                 <tr>
    279                                                     <th width="20%"></th>
    280                                                     <td width="80%">
    281                                                         <b><?php esc_html_e('Theme actions') ?></b>
    282                                                         <p>
    283                                                             <input type="checkbox" name="purge_varnish_action[theme_switch]" value="after_switch_theme" <?php
    284                                                             if ($switch_theme == 'after_switch_theme') {
    285                                                                 print 'checked="checked"';
    286                                                             }
    287                                                             ?> /> <label><?php esc_html_e('switch theme'); ?></label> <br /><span class="desc"><?php esc_html_e('Trigger when theme is switched.'); ?></span><br />
    288                                                         </p>
    289                                                     </td>
    290                                                 </tr>
    291                                                 <tr>
    292                                                     <th> </th>
    293                                                     <td>
    294                                                         <b><?php esc_html_e('What URLs should be expired when theme switch action is triggered?') ?></b>
    295                                                         <p>
    296                                                             <input type="checkbox" name="purge_varnish_expire[wp_theme_front_page]" value="front_page" <?php
    297                                                             if ($expire_wp_theme_front_page == 'front_page') {
    298                                                                 print 'checked="checked"';
    299                                                             }
    300                                                             ?> /> <label><?php esc_html_e('Front page') ?></label> <br /><span class="desc"><?php esc_html_e('Expire url of the site front page'); ?></span><br />
    301                                                             <input type="checkbox" name="purge_varnish_expire[wp_theme_purge_all]" value="purge_all" <?php
    302                                                             if ($expire_wp_theme_purge_all == 'purge_all') {
    303                                                                 print 'checked="checked"';
    304                                                             }
    305                                                             ?> class="ck_custom_url" /> <label>All varnish cache</label> <br /> <span class="desc"><?php esc_html_e('Expire/Purge all varnish cache'); ?></span><br />                             
    306 
    307                                                             <?php
    308                                                             $expire_wp_theme_custom_url_class = 'hide_custom_url';
    309                                                             $expire_wp_theme_checked = '';
    310                                                             if ($expire_wp_theme_custom_url == 'custom_url') {
    311                                                                 $expire_wp_theme_checked = 'checked="checked"';
    312                                                                 $expire_wp_theme_custom_url_class = 'show_custom_url';
    313                                                             }
    314                                                             ?>
    315                                                             <input type="checkbox" name="purge_varnish_expire[wp_theme_custom_url]" value="custom_url" <?php print $expire_wp_theme_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
    316                                                             <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span><br />
    317                                                         <div class="custom_url <?php print $expire_wp_theme_custom_url_class; ?>"><b>Enter custom URLs </b>
    318                                                             <textarea rows="3" cols="70" name="purge_varnish_expire[wp_theme_custom_urls]" class="input_custom_urls"><?php print $expire_wp_theme_custom_urls; ?></textarea>
    319                                                         </div>
    320                                                         </p>
    321                                                     </td>
    322                                                 </tr>
    323                                             </tbody>
    324                                         </table>
    325                                     </div>
    326                                     <table cellpadding="5">
    327                                         <tr>
    328                                             <th width="20%"></th>
    329                                             <td>
    330                                                 <?php wp_nonce_field('pvEsetting'); ?>
    331                                                 <input type="submit" value="Save Configurations" name="save_configurations" />
    332                                             </td>
    333                                         </tr>
    334                                     </table>
    335                                     </form>
    336                                 </div>
    337                                 </div>
     162            </div>
     163
     164            <div id="comment_expiration" class="tabcontent">
     165            <h3><?php esc_html_e('Comment expiration'); ?></h3>
     166            <table cellpadding="5">
     167                <tbody>
     168                    <tr>
     169                        <th width="20%"></th>
     170                        <td width="80%">
     171                            <b><?php esc_html_e('Comment actions') ?></b>
     172                            <p>
     173                                <input type="checkbox" name="purge_varnish_action[comment_insert]" value="wp_insert_comment" <?php
     174                                if ($comment_insert == 'wp_insert_comment') {
     175                                    print 'checked="checked"';
     176                                }
     177                                ?> /> <label><?php esc_html_e('Comment inserted'); ?></label> <br /> <span class="desc"><?php esc_html_e('Trigger when comment is posted on approved post.'); ?></span><br />
     178
     179
     180                                <input type="checkbox" name="purge_varnish_action[comment_update]" value="edit_comment" <?php
     181                                if ($comment_update == 'edit_comment') {
     182                                    print 'checked="checked"';
     183                                }
     184                                ?> /> <label><?php esc_html_e('Comment updated'); ?></label> <br /> <span class="desc"><?php esc_html_e('Trigger on approved post whenever comment is updated.'); ?></span><br />
     185
     186
     187
     188
     189                                <input type="checkbox" name="purge_varnish_action[comment_status_changed]" value="transition_comment_status" <?php
     190                                if ($comment_status_changed == 'transition_comment_status') {
     191                                    print 'checked="checked"';
     192                                }
     193                                ?> /> <label><?php esc_html_e('Comment status changed'); ?></label> <br /><span class="desc"><?php esc_html_e('Trigger when comment is approved/unapproved.'); ?></span><br />
     194
     195                            </p>
     196                        </td>
     197                    </tr>
     198                    <tr>
     199                        <th> </th>
     200                        <td>
     201                            <b><?php esc_html_e('What URLs should be expired when comment action is triggered?'); ?></b>
     202                            <p>
     203                                <input type="checkbox" name="purge_varnish_expire[comment_front_page]" value="front_page" <?php
     204                                if ($expire_comment_front_page == 'front_page') {
     205                                    print 'checked="checked"';
     206                                }
     207                                ?> /> <label><?php esc_html_e('Front page'); ?></label> <br /><span class="desc"><?php esc_html_e('Expire url of the site front page'); ?></span><br />
     208                                <input type="checkbox" name="purge_varnish_expire[comment_post_item]" value="post_item" <?php
     209                                if ($expire_comment_post_item == 'post_item') {
     210                                    print 'checked="checked"';
     211                                }
     212                                ?> /> <label><?php esc_html_e('Post page'); ?></label> <br /> <span class="desc"><?php esc_html_e('Expire url of the expiring post/page'); ?></span><br />
     213
     214                                <?php
     215                                $expire_comment_custom_url_class = 'hide_custom_url';
     216                                $expire_comment_checked = '';
     217                                if ($expire_comment_custom_url == 'custom_url') {
     218                                    $expire_comment_checked = 'checked="checked"';
     219                                    $expire_comment_custom_url_class = 'show_custom_url';
     220                                }
     221                                ?>
     222                                <input type="checkbox" name="purge_varnish_expire[comment_custom_url]" value="custom_url" <?php print $expire_comment_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
     223                                <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span><br />
     224                            <div class="custom_url <?php print $expire_comment_custom_url_class; ?>">
     225                                <textarea rows="3" cols="70" name="purge_varnish_expire[comment_custom_urls]" class="input_custom_urls"><?php print $expire_comment_custom_urls; ?></textarea>
     226                            </div>
     227                            </p>
     228                        </td>
     229                    </tr>
     230                </tbody>
     231            </table>
     232        </div>
     233
     234        <div id="menu_expiration" class="tabcontent">
     235            <h3><?php esc_html_e('Menu links expiration'); ?></h3>
     236            <table cellpadding="5">
     237                <tbody>
     238                    <tr>
     239                        <th width="20%"></th>
     240                        <td width="80%">
     241                            <b><?php esc_html_e('Menu link actions') ?></b>
     242                            <p>
     243                                <input type="checkbox" name="purge_varnish_action[navmenu_insert_update]" value="wp_update_nav_menu" <?php
     244                                if ($navmenu_insert_update == 'wp_update_nav_menu') {
     245                                    print 'checked="checked"';
     246                                }
     247                                ?> /> <label><?php esc_html_e('Menu link insert/update/delete'); ?></label> <br /> <span class="desc"><?php esc_html_e('Trigger on menu save action.'); ?></span><br />
     248                            </p>
     249                        </td>
     250                    </tr>
     251                    <tr>
     252                        <th> </th>
     253                        <td>
     254                            <b><?php esc_html_e('What URLs should be expired when menu save action is triggered?') ?></b>
     255                            <p>
     256                                <input type="checkbox" name="purge_varnish_expire[navmenu_front_page]" value="front_page" <?php
     257                                if ($expire_navmenu_front_page == 'front_page') {
     258                                    print 'checked="checked"';
     259                                }
     260                                ?> /> <label><?php esc_html_e('Front page'); ?></label> <br /><span class="desc"><?php esc_html_e('Expire url of the site front page'); ?></span><br />
     261                                <input type="checkbox" name="purge_varnish_expire[navmenu_menu_link]" value="menu_item" <?php
     262                                if ($expire_navmenu_link == 'menu_item') {
     263                                    print 'checked="checked"';
     264                                }
     265                                ?> /> <label><?php esc_html_e('Menu links'); ?></label> <br /> <span class="desc"><?php esc_html_e('Expire url of menu links'); ?></span><br />
     266
     267                                <?php
     268                                $expire_navmenu_custom_url_class = 'hide_custom_url';
     269                                $expire_navmenu_checked = '';
     270                                if ($expire_navmenu_custom_url == 'custom_url') {
     271                                    $expire_navmenu_checked = 'checked="checked"';
     272                                    $expire_navmenu_custom_url_class = 'show_custom_url';
     273                                }
     274                                ?>
     275                                <input type="checkbox" name="purge_varnish_expire[navmenu_custom_url]" value="custom_url" <?php print $expire_navmenu_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
     276                                <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span><br />
     277                            <div class="custom_url <?php print $expire_navmenu_custom_url_class; ?>">
     278                                <textarea rows="3" cols="70" name="purge_varnish_expire[navmenu_custom_urls]" class="input_custom_urls"><?php print $expire_navmenu_custom_urls; ?></textarea>
     279                            </div>
     280                            </p>
     281                        </td>
     282                    </tr>
     283                </tbody>
     284            </table>
     285        </div>
     286
     287        <div id="switch_theme" class="tabcontent">
     288            <h3><?php esc_html_e('Switch theme expiration'); ?></h3>
     289            <table cellpadding="5">
     290                <tbody>
     291                    <tr>
     292                        <th width="20%"></th>
     293                        <td width="80%">
     294                            <b><?php esc_html_e('Theme actions') ?></b>
     295                            <p>
     296                                <input type="checkbox" name="purge_varnish_action[theme_switch]" value="after_switch_theme" <?php
     297                                if ($switch_theme == 'after_switch_theme') {
     298                                    print 'checked="checked"';
     299                                }
     300                                ?> /> <label><?php esc_html_e('switch theme'); ?></label> <br /><span class="desc"><?php esc_html_e('Trigger when theme is switched.'); ?></span><br />
     301                            </p>
     302                        </td>
     303                    </tr>
     304                    <tr>
     305                        <th> </th>
     306                        <td>
     307                            <b><?php esc_html_e('What URLs should be expired when theme switch action is triggered?') ?></b>
     308                            <p>
     309                                <input type="checkbox" name="purge_varnish_expire[wp_theme_front_page]" value="front_page" <?php
     310                                if ($expire_wp_theme_front_page == 'front_page') {
     311                                    print 'checked="checked"';
     312                                }
     313                                ?> /> <label><?php esc_html_e('Front page') ?></label> <br /><span class="desc"><?php esc_html_e('Expire url of the site front page'); ?></span><br />
     314                                <input type="checkbox" name="purge_varnish_expire[wp_theme_purge_all]" value="purge_all" <?php
     315                                if ($expire_wp_theme_purge_all == 'purge_all') {
     316                                    print 'checked="checked"';
     317                                }
     318                                ?> class="ck_custom_url" /> <label>All varnish cache</label> <br /> <span class="desc"><?php esc_html_e('Expire/Purge all varnish cache'); ?></span><br />                             
     319
     320                                <?php
     321                                $expire_wp_theme_custom_url_class = 'hide_custom_url';
     322                                $expire_wp_theme_checked = '';
     323                                if ($expire_wp_theme_custom_url == 'custom_url') {
     324                                    $expire_wp_theme_checked = 'checked="checked"';
     325                                    $expire_wp_theme_custom_url_class = 'show_custom_url';
     326                                }
     327                                ?>
     328                                <input type="checkbox" name="purge_varnish_expire[wp_theme_custom_url]" value="custom_url" <?php print $expire_wp_theme_checked; ?> class="ck_custom_url" /> <label><?php esc_html_e('Custom URLs'); ?></label> <br />
     329                                <span class="desc"><?php esc_html_e('Expire user-defined custom urls.'); ?></span><br />
     330                            <div class="custom_url <?php print $expire_wp_theme_custom_url_class; ?>">
     331                                <textarea rows="3" cols="70" name="purge_varnish_expire[wp_theme_custom_urls]" class="input_custom_urls"><?php print $expire_wp_theme_custom_urls; ?></textarea>
     332                            </div>
     333                            </p>
     334                        </td>
     335                    </tr>
     336                </tbody>
     337            </table>
     338        </div>
     339        <table cellpadding="5">
     340            <tr>
     341                <th width="20%"></th>
     342                <td>
     343                    <?php wp_nonce_field('pvEsetting'); ?>
     344                    <input type="submit" value="Save Configurations" name="save_configurations" />
     345                </td>
     346            </tr>
     347        </table>
     348        </form>
     349    </div>
     350</div>
  • purge-varnish/trunk/js/purge_varnish.js

    r1624809 r1906488  
    1414    }
    1515});
    16 
    1716 
    1817});
  • purge-varnish/trunk/readme.txt

    r1758930 r1906488  
    55Requires at least: 4.0
    66Tested up to: 4.8.1
    7 Stable tag: 1.0.7
     7Stable tag: 1.0.8
    88License: GPLv2 or later
    99
     
    108108== ChangeLog ==
    109109
     110= 1.0.8 =
     111
     112Fix:
     1131.  Wrong number of arguments’ errors filling up logs.
     1142.  Purge Varnish cache on comment post/update on published post.
    110115
    111116= 1.0.7 =
Note: See TracChangeset for help on using the changeset viewer.