Plugin Directory

Changeset 2683664


Ignore:
Timestamp:
02/23/2022 11:10:57 AM (4 years ago)
Author:
Lugat
Message:

Disable admin controls for trash and not published posts.

Location:
jinx-fast-cache/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • jinx-fast-cache/trunk/index.php

    r2676369 r2683664  
    22 
    33  /**
    4    * Plugin Name: Jinx Fast Cache
     4   * Plugin Name: Jinx Fast-Cache
    55   * Plugin URI: https://wordpress.org/plugins/jixn-fast-cache/
    66   * Description: Blazing fast full page cache.
    7    * Version: 0.3.4
     7   * Version: 0.3.5
    88   * Author: SquareFlower Websolutions (Lukas Rydygel) <hallo@squareflower.de>
    99   * Author URI: http://squareflower.de
  • jinx-fast-cache/trunk/readme.txt

    r2676385 r2683664  
    55Tested up to: 5.9.0
    66Requires PHP: 7.0
    7 Stable tag: 0.3.4
     7Stable tag: 0.3.5
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • jinx-fast-cache/trunk/src/Admin.php

    r2676361 r2683664  
    6969
    7070            global $post;
    71 
    72             $nodes = array_merge($nodes, self::createNodes('post', ['%s Post # %d', $post->ID], [
    73               'post_type' => $post->post_type,
    74               $post->ID
    75             ]));
     71           
     72            if ($post->post_status === 'publish') {
     73
     74              $nodes = array_merge($nodes, self::createNodes('post', ['%s Post # %d', $post->ID], [
     75                'post_type' => $post->post_type,
     76                $post->ID
     77              ]));
     78           
     79            }
    7680
    7781          }
     
    276280    public static function addPostColumnContent(string $key, int $pid)
    277281    {
    278        
     282     
    279283      if ($key === 'jinx-fast-cache') {
    280284       
     285        $post = get_post($pid);
    281286        $url = get_permalink($pid);
    282287       
    283         echo self::getColumnContent($url);
     288        echo self::getColumnContent($url, $post->post_status !== 'publish');
    284289
    285290      }
     
    311316     *
    312317     * @param string $url
     318     * @param bool $disabled
    313319     * @return string
    314320     */
    315     protected static function getColumnContent(string $url) : string
    316     {
    317      
    318       $status = Url::getStatus($url);
     321    protected static function getColumnContent(string $url, bool $disabled = false) : string
     322    {
     323     
     324      if ($disabled === true) {
     325        $status = 'disabled';
     326      } else {
     327        $status = Url::getStatus($url);
     328      }
    319329     
    320330      $icons = [
    321         '&#128308',
     331        'not cached' => '&#128308',
    322332        'warming' => '&#128993;',
    323333        'cached' => '&#128994;',
     334        'disabled' => '&#9898;'
    324335      ];
    325336     
    326       return '<span title="'.Plugin::t($status).'">'.($icons[$status] ?? $icons[0]).'</span>';
     337      return '<span title="'.Plugin::t($status).'">'.($icons[$status] ?? $icons['not cached']).'</span>';
    327338     
    328339    }
     
    338349    {
    339350     
    340       return array_merge($actions, self::createActions([
    341         'post_type' => $post->post_type,
    342         $post->ID
    343       ]));
     351      if ($post->post_status === 'publish') {
     352       
     353        $actions = array_merge($actions, self::createActions([
     354          'post_type' => $post->post_type,
     355          $post->ID
     356        ]));
     357       
     358      }
     359     
     360      return $actions;
    344361           
    345362    }
Note: See TracChangeset for help on using the changeset viewer.