Plugin Directory

Changeset 2624380


Ignore:
Timestamp:
11/04/2021 08:29:27 AM (4 years ago)
Author:
_luigi
Message:

Publishing The Permalinks Cascade 2.0.3

Location:
the-permalinks-cascade
Files:
12 edited
11 copied

Legend:

Unmodified
Added
Removed
  • the-permalinks-cascade/tags/2.0.3/admin/admin-controller.class.php

    r2608713 r2624380  
    3535
    3636    /**
    37      * Local copy of the global $pagenow.
    38      *
    39      * @since 1.0
    40      * @var string
    41      */
    42     private $wpAdminPageID;
    43 
    44     /**
    4537     * @since 1.0
    4638     * @param string
     
    5345     */
    5446    public function __construct( $plugin ) {
    55         global $pagenow;
    56 
    5747        $this->plugin         = $plugin;
    5848        $this->db             = $plugin->db();
    59         $this->wpAdminPageID  = $pagenow;
    6049        $this->dataController = $plugin->invokeGlobalObject( 'DataController' );
    6150    }
     
    170159        $page = $this->dataController->page( $page_id );
    171160       
    172         if ( !( $page && ( $page->parentSlug() == $this->wpAdminPageID ) ) ) {
     161        if (! $page ) {
    173162            wp_die( __( 'Request sent to a non existent page.', 'the-permalinks-cascade' ) );
    174163        }
     
    218207     */
    219208    private function registerActions() {
     209        global $pagenow;
     210
    220211        add_action( 'admin_menu', array( $this, 'registerAdminPages' ) );
    221212        add_action( 'admin_enqueue_scripts', array( $this, 'enqueueStylesAndScripts' ) );
    222213
    223         switch ( $this->wpAdminPageID ) {
     214        switch ( $pagenow ) {
    224215            case 'post.php':
    225216            case 'post-new.php':
     
    348339     */
    349340    public function registerAdminPages() {
    350         $pages              = $this->dataController->pages( false );
    351         $first_page_menu_id = $pages[0]->namespacedID();
    352 
    353         add_menu_page( 'The Permalinks Cascade', 'The Permalinks Cascade', 'manage_options', $first_page_menu_id,
    354                        '__return_false', $this->getBase64MenuIcon(), 90 );
     341        $pages     = $this->dataController->pages( false );
     342        $dashboard = $pages[0];
     343       
     344        if ( $dashboard->namespacedID() === $dashboard->parentSlug() ) {
     345            $menu_title_ns = '';
     346
     347            add_menu_page( 'The Permalinks Cascade', 'The Permalinks Cascade', 'manage_options', $dashboard->namespacedID(),
     348                           '__return_false', $this->getBase64MenuIcon(), 90 );
     349        }
     350        else {
     351            $menu_title_ns = 'TPC - ';
     352        }
    355353
    356354        foreach ( $pages as $page ) {
    357             $menu_page_id = $page->namespacedID();
     355            $page_ns_id = $page->namespacedID();
    358356           
    359             if (
    360                 isset( $_GET['page'] ) &&
    361                 ( $menu_page_id == $_GET['page'] ) &&
    362                 ( $page->parentSlug() == $this->wpAdminPageID )
    363             ) {
     357            if ( isset( $_GET['page'] ) && ( $page_ns_id == $_GET['page'] ) ) {
    364358                $this->plugin->load( 'admin/field-view.class.php' );
    365359                $this->plugin->load( 'admin/page-view.class.php' );
     
    371365                }
    372366
    373                 $this->currentTPCAdminPageID = $menu_page_id;
     367                $this->currentTPCAdminPageID = $page_ns_id;
    374368
    375369                $pageController     = PageController::makeController( $page, $this->plugin, $this->dataController );
     
    382376            }
    383377
    384             add_submenu_page( $first_page_menu_id, $page->title(), $page->menuTitle(), 'manage_options',
    385                               $menu_page_id, $menu_page_callback );
     378            $menu_title = $menu_title_ns . $page->menuTitle();
     379
     380            add_submenu_page( $page->parentSlug(), $page->title(), $menu_title, 'manage_options',
     381                              $page_ns_id, $menu_page_callback );
    386382        }
    387383    }
  • the-permalinks-cascade/tags/2.0.3/admin/page-controller-classes.php

    r2608713 r2624380  
    185185                $arguments['tpc_nonce'] = wp_create_nonce( $arguments['action'] );
    186186            }
    187         }
    188 
    189 
    190         return add_query_arg( $arguments, admin_url( $page->parentSlug() ) );
     187        }
     188
     189        if ( '.php' === substr( $page->parentSlug(), -4 ) ) {
     190            $admin_url = admin_url( $page->parentSlug() );
     191        }
     192        else {
     193            $admin_url = admin_url( 'admin.php' );
     194        }
     195
     196        return add_query_arg( $arguments, $admin_url );
    191197    }
    192198   
  • the-permalinks-cascade/tags/2.0.3/data-model/data-controller.class.php

    r2608713 r2624380  
    6767            Page::setNamespace( 'tpc' );
    6868
    69             $this->pages[] = new Page( 'dashboard', '', __( 'Dashboard', 'the-permalinks-cascade' ),
     69            $this->pages[] = new Page( 'dashboard', 'tpc-dashboard', __( 'Dashboard', 'the-permalinks-cascade' ),
    7070                                       __( 'Dashboard', 'the-permalinks-cascade' ), 'DashboardPageView', 'DashboardController' );
    7171           
    7272            if ( $include_non_active || $this->plugin->isSitemapActive( 'site_tree' ) ) {
    73                 $this->pages[] = new Page( 'site_tree', '', __( 'Site Tree Settings', 'the-permalinks-cascade' ),
     73                $this->pages[] = new Page( 'site_tree', 'tpc-dashboard', __( 'Site Tree Settings', 'the-permalinks-cascade' ),
    7474                                           __( 'Site Tree Settings', 'the-permalinks-cascade' ), 'PageView', 'PageController' );
    7575            }
    7676
    77             $this->pages[] = new Page( 'advanced', '', __( 'Advanced Settings', 'the-permalinks-cascade' ),
     77            $this->pages[] = new Page( 'advanced', 'tpc-dashboard', __( 'Advanced Settings', 'the-permalinks-cascade' ),
    7878                                       __( 'Advanced Settings', 'the-permalinks-cascade' ), 'PageView', 'PageController' );
    7979        }
  • the-permalinks-cascade/tags/2.0.3/data-model/data-model-classes.php

    r2608713 r2624380  
    2525     * @var string
    2626     */
    27     protected $menuID;
    28    
    29     /**
    30      * @since 1.0
    31      * @var string
    32      */
    3327    protected $title;
    3428   
     
    6963     *
    7064     * @param string $id
    71      * @param string $menu_id
     65     * @param string $parent_slug
    7266     * @param string $title
    7367     * @param string $menu_title
     
    7569     * @param string $controller_class
    7670     */
    77     public function __construct( $id, $menu_id, $title,
     71    public function __construct( $id, $parent_slug, $title,
    7872                                 $menu_title, $view_class, $controller_class )
    7973    {
    8074        $this->id              = $id;
    81         $this->menuID          = $menu_id;
    8275        $this->title           = $title;
    8376        $this->menuTitle       = $menu_title;
    8477        $this->viewClass       = $view_class;
    8578        $this->controllerClass = $controller_class;
     79
     80        /**
     81         * @since 2.0.3
     82         */
     83        $this->parentSlug = apply_filters( 'tpc_admin_page_parent_slug', $parent_slug, $id );
    8684    }
    8785   
     
    106104     * @return string
    107105     */
    108     public function menuID() {
    109         return $this->menuID;
    110     }
    111 
    112     /**
    113      * @since 1.0
    114      * @return string
    115      */
    116106    public function title() {
    117107        return $this->title;
     
    147137     */
    148138    public function parentSlug() {
    149         if (! $this->parentSlug ) {
    150             if ( false === strpos( $this->menuID, '.php' ) ) {
    151                 $this->parentSlug = 'admin.php';
    152             }
    153             else {
    154                 $this->parentSlug = $this->menuID;
    155             }
    156         }
    157        
    158         return $this->parentSlug;
     139        return $this->parentSlug;
    159140    }
    160141}
  • the-permalinks-cascade/tags/2.0.3/includes/modules/wpml-module.class.php

    r2608713 r2624380  
    142142                add_filter( 'tpc_ping_controller_can_ping', array( $this, 'tpcPingControllerCanPing' ), 10, 3 );
    143143                break;
    144             case 'admin.php':
     144            default:
    145145                add_filter( 'tpc_dashboard_page_data_pages_dropdown_query',
    146146                            array( $this, 'tpcDashboardPageDataPagesDropdownQuery' ) );
    147147                add_filter( 'tpc_data_controller_sanitised_option_value',
    148148                            array( $this, 'tpcDataControllerSanitisedOptionValue' ), 10, 3 );
    149                 break;
    150149        }
    151150    }
  • the-permalinks-cascade/tags/2.0.3/readme.txt

    r2608713 r2624380  
    66Tags: html site map, google sitemap, news sitemap, lists, blocks
    77Requires at least: 5.8
    8 Tested up to: 5.8.1
     8Tested up to: 5.8
    99Requires PHP: 7.0
    10 Stable tag: 2.0.2
     10Stable tag: 2.0.3
    1111License: GPLv3
    1212License URI: https://opensource.org/licenses/GPL-3.0
     
    145145== Upgrade Notice ==
    146146
    147 = 2.0.2 =
     147= 2.0.3 =
    148148
    149 The Permalinks Cascade is available on WordPress.org.
     149Added a superuser mini-feature.
    150150
    151151
    152152== Changelog ==
     153
     154= 2.0.3 (4 November 2021) =
     155
     156Now you can move the plugin's admin menu to a parent menu of your choice. In [this article](https://luigicavalieri.com/the-permalinks-cascade/help/moving-admin-menu/) is explained how.
    153157
    154158= 2.0.2 (4 October 2021) =
  • the-permalinks-cascade/tags/2.0.3/the-permalinks-cascade.php

    r2608713 r2624380  
    44 * Plugin URI: https://luigicavalieri.com/the-permalinks-cascade/
    55 * Description: Sitemaps, Hyper-lists and Beyond.
    6  * Version: 2.0.2
     6 * Version: 2.0.3
    77 * Requires: 5.8
    88 * Author: Luigi Cavalieri
     
    1313 *
    1414 * @package The Permalinks Cascade
    15  * @version 2.0.2
     15 * @version 2.0.3
    1616 * @copyright Copyright 2021 Luigi Cavalieri.
    1717 * @license https://opensource.org/licenses/GPL-3.0 GPL v3.0
  • the-permalinks-cascade/trunk/admin/admin-controller.class.php

    r2608713 r2624380  
    3535
    3636    /**
    37      * Local copy of the global $pagenow.
    38      *
    39      * @since 1.0
    40      * @var string
    41      */
    42     private $wpAdminPageID;
    43 
    44     /**
    4537     * @since 1.0
    4638     * @param string
     
    5345     */
    5446    public function __construct( $plugin ) {
    55         global $pagenow;
    56 
    5747        $this->plugin         = $plugin;
    5848        $this->db             = $plugin->db();
    59         $this->wpAdminPageID  = $pagenow;
    6049        $this->dataController = $plugin->invokeGlobalObject( 'DataController' );
    6150    }
     
    170159        $page = $this->dataController->page( $page_id );
    171160       
    172         if ( !( $page && ( $page->parentSlug() == $this->wpAdminPageID ) ) ) {
     161        if (! $page ) {
    173162            wp_die( __( 'Request sent to a non existent page.', 'the-permalinks-cascade' ) );
    174163        }
     
    218207     */
    219208    private function registerActions() {
     209        global $pagenow;
     210
    220211        add_action( 'admin_menu', array( $this, 'registerAdminPages' ) );
    221212        add_action( 'admin_enqueue_scripts', array( $this, 'enqueueStylesAndScripts' ) );
    222213
    223         switch ( $this->wpAdminPageID ) {
     214        switch ( $pagenow ) {
    224215            case 'post.php':
    225216            case 'post-new.php':
     
    348339     */
    349340    public function registerAdminPages() {
    350         $pages              = $this->dataController->pages( false );
    351         $first_page_menu_id = $pages[0]->namespacedID();
    352 
    353         add_menu_page( 'The Permalinks Cascade', 'The Permalinks Cascade', 'manage_options', $first_page_menu_id,
    354                        '__return_false', $this->getBase64MenuIcon(), 90 );
     341        $pages     = $this->dataController->pages( false );
     342        $dashboard = $pages[0];
     343       
     344        if ( $dashboard->namespacedID() === $dashboard->parentSlug() ) {
     345            $menu_title_ns = '';
     346
     347            add_menu_page( 'The Permalinks Cascade', 'The Permalinks Cascade', 'manage_options', $dashboard->namespacedID(),
     348                           '__return_false', $this->getBase64MenuIcon(), 90 );
     349        }
     350        else {
     351            $menu_title_ns = 'TPC - ';
     352        }
    355353
    356354        foreach ( $pages as $page ) {
    357             $menu_page_id = $page->namespacedID();
     355            $page_ns_id = $page->namespacedID();
    358356           
    359             if (
    360                 isset( $_GET['page'] ) &&
    361                 ( $menu_page_id == $_GET['page'] ) &&
    362                 ( $page->parentSlug() == $this->wpAdminPageID )
    363             ) {
     357            if ( isset( $_GET['page'] ) && ( $page_ns_id == $_GET['page'] ) ) {
    364358                $this->plugin->load( 'admin/field-view.class.php' );
    365359                $this->plugin->load( 'admin/page-view.class.php' );
     
    371365                }
    372366
    373                 $this->currentTPCAdminPageID = $menu_page_id;
     367                $this->currentTPCAdminPageID = $page_ns_id;
    374368
    375369                $pageController     = PageController::makeController( $page, $this->plugin, $this->dataController );
     
    382376            }
    383377
    384             add_submenu_page( $first_page_menu_id, $page->title(), $page->menuTitle(), 'manage_options',
    385                               $menu_page_id, $menu_page_callback );
     378            $menu_title = $menu_title_ns . $page->menuTitle();
     379
     380            add_submenu_page( $page->parentSlug(), $page->title(), $menu_title, 'manage_options',
     381                              $page_ns_id, $menu_page_callback );
    386382        }
    387383    }
  • the-permalinks-cascade/trunk/admin/page-controller-classes.php

    r2608713 r2624380  
    185185                $arguments['tpc_nonce'] = wp_create_nonce( $arguments['action'] );
    186186            }
    187         }
    188 
    189 
    190         return add_query_arg( $arguments, admin_url( $page->parentSlug() ) );
     187        }
     188
     189        if ( '.php' === substr( $page->parentSlug(), -4 ) ) {
     190            $admin_url = admin_url( $page->parentSlug() );
     191        }
     192        else {
     193            $admin_url = admin_url( 'admin.php' );
     194        }
     195
     196        return add_query_arg( $arguments, $admin_url );
    191197    }
    192198   
  • the-permalinks-cascade/trunk/data-model/data-controller.class.php

    r2608713 r2624380  
    6767            Page::setNamespace( 'tpc' );
    6868
    69             $this->pages[] = new Page( 'dashboard', '', __( 'Dashboard', 'the-permalinks-cascade' ),
     69            $this->pages[] = new Page( 'dashboard', 'tpc-dashboard', __( 'Dashboard', 'the-permalinks-cascade' ),
    7070                                       __( 'Dashboard', 'the-permalinks-cascade' ), 'DashboardPageView', 'DashboardController' );
    7171           
    7272            if ( $include_non_active || $this->plugin->isSitemapActive( 'site_tree' ) ) {
    73                 $this->pages[] = new Page( 'site_tree', '', __( 'Site Tree Settings', 'the-permalinks-cascade' ),
     73                $this->pages[] = new Page( 'site_tree', 'tpc-dashboard', __( 'Site Tree Settings', 'the-permalinks-cascade' ),
    7474                                           __( 'Site Tree Settings', 'the-permalinks-cascade' ), 'PageView', 'PageController' );
    7575            }
    7676
    77             $this->pages[] = new Page( 'advanced', '', __( 'Advanced Settings', 'the-permalinks-cascade' ),
     77            $this->pages[] = new Page( 'advanced', 'tpc-dashboard', __( 'Advanced Settings', 'the-permalinks-cascade' ),
    7878                                       __( 'Advanced Settings', 'the-permalinks-cascade' ), 'PageView', 'PageController' );
    7979        }
  • the-permalinks-cascade/trunk/data-model/data-model-classes.php

    r2608713 r2624380  
    2525     * @var string
    2626     */
    27     protected $menuID;
    28    
    29     /**
    30      * @since 1.0
    31      * @var string
    32      */
    3327    protected $title;
    3428   
     
    6963     *
    7064     * @param string $id
    71      * @param string $menu_id
     65     * @param string $parent_slug
    7266     * @param string $title
    7367     * @param string $menu_title
     
    7569     * @param string $controller_class
    7670     */
    77     public function __construct( $id, $menu_id, $title,
     71    public function __construct( $id, $parent_slug, $title,
    7872                                 $menu_title, $view_class, $controller_class )
    7973    {
    8074        $this->id              = $id;
    81         $this->menuID          = $menu_id;
    8275        $this->title           = $title;
    8376        $this->menuTitle       = $menu_title;
    8477        $this->viewClass       = $view_class;
    8578        $this->controllerClass = $controller_class;
     79
     80        /**
     81         * @since 2.0.3
     82         */
     83        $this->parentSlug = apply_filters( 'tpc_admin_page_parent_slug', $parent_slug, $id );
    8684    }
    8785   
     
    106104     * @return string
    107105     */
    108     public function menuID() {
    109         return $this->menuID;
    110     }
    111 
    112     /**
    113      * @since 1.0
    114      * @return string
    115      */
    116106    public function title() {
    117107        return $this->title;
     
    147137     */
    148138    public function parentSlug() {
    149         if (! $this->parentSlug ) {
    150             if ( false === strpos( $this->menuID, '.php' ) ) {
    151                 $this->parentSlug = 'admin.php';
    152             }
    153             else {
    154                 $this->parentSlug = $this->menuID;
    155             }
    156         }
    157        
    158         return $this->parentSlug;
     139        return $this->parentSlug;
    159140    }
    160141}
  • the-permalinks-cascade/trunk/includes/modules/wpml-module.class.php

    r2608713 r2624380  
    142142                add_filter( 'tpc_ping_controller_can_ping', array( $this, 'tpcPingControllerCanPing' ), 10, 3 );
    143143                break;
    144             case 'admin.php':
     144            default:
    145145                add_filter( 'tpc_dashboard_page_data_pages_dropdown_query',
    146146                            array( $this, 'tpcDashboardPageDataPagesDropdownQuery' ) );
    147147                add_filter( 'tpc_data_controller_sanitised_option_value',
    148148                            array( $this, 'tpcDataControllerSanitisedOptionValue' ), 10, 3 );
    149                 break;
    150149        }
    151150    }
  • the-permalinks-cascade/trunk/readme.txt

    r2608713 r2624380  
    66Tags: html site map, google sitemap, news sitemap, lists, blocks
    77Requires at least: 5.8
    8 Tested up to: 5.8.1
     8Tested up to: 5.8
    99Requires PHP: 7.0
    10 Stable tag: 2.0.2
     10Stable tag: 2.0.3
    1111License: GPLv3
    1212License URI: https://opensource.org/licenses/GPL-3.0
     
    145145== Upgrade Notice ==
    146146
    147 = 2.0.2 =
     147= 2.0.3 =
    148148
    149 The Permalinks Cascade is available on WordPress.org.
     149Added a superuser mini-feature.
    150150
    151151
    152152== Changelog ==
     153
     154= 2.0.3 (4 November 2021) =
     155
     156Now you can move the plugin's admin menu to a parent menu of your choice. In [this article](https://luigicavalieri.com/the-permalinks-cascade/help/moving-admin-menu/) is explained how.
    153157
    154158= 2.0.2 (4 October 2021) =
  • the-permalinks-cascade/trunk/the-permalinks-cascade.php

    r2608713 r2624380  
    44 * Plugin URI: https://luigicavalieri.com/the-permalinks-cascade/
    55 * Description: Sitemaps, Hyper-lists and Beyond.
    6  * Version: 2.0.2
     6 * Version: 2.0.3
    77 * Requires: 5.8
    88 * Author: Luigi Cavalieri
     
    1313 *
    1414 * @package The Permalinks Cascade
    15  * @version 2.0.2
     15 * @version 2.0.3
    1616 * @copyright Copyright 2021 Luigi Cavalieri.
    1717 * @license https://opensource.org/licenses/GPL-3.0 GPL v3.0
Note: See TracChangeset for help on using the changeset viewer.