Plugin Directory

Changeset 2981804

Timestamp:
10/20/2023 05:14:28 PM (10 months ago)
Author:
mrwweb
Message:

Update to version 1.5.0 from GitHub

Location:
post-type-archive-descriptions
Files:
21 edited
1 copied

Legend:

Unmodified
Added
Removed
  • post-type-archive-descriptions/assets/icon.svg

    • Property svn:mime-type set to image/svg+xml
  • post-type-archive-descriptions/tags/1.5.0/changelog.txt

    r2745967 r2981804  
     1
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
    114= 1.3.1 (June 21, 2022) =
    215* Tested up to 6.0.
  • post-type-archive-descriptions/tags/1.5.0/compat/qtranslate-x.php

    r2470184 r2981804  
    11<?php
    22/**
    3  * One additional line of compatability is in the `ptad_editor_field` function of the main plugin
     3 * One additional line of compatability is in the `ptad_editor_field` function of the main plugin
    44 */
    55if ( ! defined( 'QTX_VERSION' ) ) {
    66
    77    add_filter( 'ptad_wp_editor_settings', 'ptad_qtranslate_editor_args' );
    8 
    98    /**
    109     * filter editor settings to add necessary text editor classes for support
     
    1312     */
    1413    function ptad_qtranslate_editor_args( $editor_settings ) {
    15          $editor_settings['classes'] = $editor_settings['classes'] . ' multilanguage-input qtranxs-translatable';
     14        $editor_settings['classes'] = $editor_settings['classes'] . ' multilanguage-input qtranxs-translatable';
    1615
    17          return $editor_settings;
     16        return $editor_settings;
    1817    }
    19    
    20     add_filter('qtranslate_load_admin_page_config', 'ptad_qtranslate_support', 99); // 99 priority is important, loaded after registered post types
    2118
     19
     20
    2221    /**
    2322     * filter qtranslate so it knows to pay attention on archive description editor pages
     
    2524    function ptad_qtranslate_support( $page_configs ) {
    2625
    27         //edit.php?post_type=$post_type&page=
    2826        $page_config = array();
    29        
    30         //get post types
     27
     28        //get post types
    3129        $post_types = ptad_get_post_types();
    3230
     
    3432        foreach ( $post_types as $post_type ) {
    3533
    36             if( post_type_exists( $post_type ) ) {
     34            if( post_type_exists( $post_type ) ) {
    3735                $page_config['pages'] = array( 'edit.php' => 'post_type=' . $post_type . '&page=' );
    3836            }
    39            
    4037        }
    4138
     
    4542
    4643        $f['fields'] = array();
    47         $fields = &$f['fields'];
     44        $fields = &$f['fields'];
    4845
    4946        //textarea support
     
    5148
    5249        $page_config['forms'][] = $f;
    53         $page_configs[] = $page_config;
     50        $page_configs[] = $page_config;
    5451
    5552        return $page_configs;
    5653
    5754    }
    58 
    5955}
  • post-type-archive-descriptions/tags/1.5.0/compat/the-events-calendar.php

    r2745967 r2981804  
    11<?php
     2
    23/**
    34 * Set the template which the Archive Description should appear before in v2 Tribe Events templates - OR - disable automatic output of archive description on Events templates with false
    45 */
    5 $before_template = apply_filters( 'ptad_tribe_template_before_include', 'events/v2/components/events-bar' );
    6 if( $before_template ) {
     6function ptad_tec_description() {
     7    $before_template = apply_filters(
     8        'ptad_tribe_template_before_include',
     9        'events/v2/components/before'
     10    );
     11    if ( $before_template ) {
    712
    8     add_action( 'tribe_template_before_include:' . esc_attr( $before_template ), 'ptad_tribe_events_archive_header' );
    9     /**
    10      * Add Title to Events Pages
    11      */
    12     function ptad_tribe_events_archive_header() {
    13 
    14         if( is_post_type_archive() && in_array( 'tribe_events', ptad_get_post_types() ) ) {
    15             the_archive_description( '<div class="archive-description">', '</div>' );
     13        add_action( 'tribe_template_before_include:' . esc_attr( $before_template ), 'ptad_tribe_events_archive_header' );
     14        /**
     15         * Add Title to Events Pages
     16         */
     17        function ptad_tribe_events_archive_header() {
     18            if (
     19                is_post_type_archive() &&
     20                in_array( 'tribe_events', ptad_get_post_types(), true )
     21            ) {
     22                the_archive_description( '<div class="archive-description">', '</div>' );
     23            }
    1624        }
    17 
    1825    }
    19 
    2026}
  • post-type-archive-descriptions/tags/1.5.0/compat/wordpress-core.php

    r2470184 r2981804  
    11<?php
    2 /****************************************************
    3  *
    4  * Automatically display content if using *_archive_description() introduced in WordPress 4.1!
    5  *
    6  ****************************************************/
     2/**
     3 * Automatically display content if using get_archive_description() or the_archive_description() functions introduced in WordPress 4.1!
     4 */
    75add_filter( 'get_the_archive_description', 'ptad_archive_description' );
    86
     
    1311 */
    1412function ptad_archive_description( $description ) {
    15     if( is_post_type_archive( ptad_get_post_types() ) ) {
     13    if( is_post_type_archive( ptad_get_post_types() ) ) {
    1614        $description = ptad_get_post_type_description();
    1715    }
  • post-type-archive-descriptions/tags/1.5.0/inc/admin-bar.php

    r2745967 r2981804  
    11<?php
    2 /****************************************************
    3  *
     2/**
    43 * Add Edit / View Links to the WordPress Admin Bar
    5  * 
     4 *
    65 * Props: blog.rutwick.com/add-items-anywhere-to-the-wp-3-3-admin-bar
    7  *
    8  ****************************************************/
     6 */
    97
     8
    109/**
    1110 * add links to view/edit archive in the admin bar
     
    1312function ptad_admin_bar_links( $admin_bar ) {
    1413
    15     if(
     14    if(
    1615        ! is_admin()
    1716        && is_post_type_archive( ptad_get_post_types() )
    1817        && current_user_can( ptad_allow_edit_posts() )
    19      ) {
    20         $post_type = ptad_get_post_type_from_queried_object();
     18    ) {
     19        $post_type = ptad_get_post_type_from_queried_object();
    2120        $post_type_object = get_post_type_object( $post_type );
    2221
    23         if( is_object( $post_type_object ) ) {
     22        if( is_object( $post_type_object ) ) {
    2423
    2524            $post_type_name = $post_type_object->labels->name;
    2625
    27             $link_text = sprintf( __( 'Edit %1$s Description', 'post-type-archive-descriptions' ), $post_type_name );
     26            /* translators: %s: post type name */
     27            $link_text = sprintf( __( 'Edit %s Description', 'post-type-archive-descriptions' ), $post_type_name );
    2828
    2929            /**
     
    3535
    3636            $parent_page = ptad_settings_page_parent( $post_type, $post_type_object->show_in_menu );
    37            
     37
    3838            $args = array(
    3939                'id'    => 'wp-admin-bar-edit',
    4040                'title' => $link_text,
    41                 'href'  => admin_url( $parent_page . '&page=' . $post_type . '-description' )
     41                'href'  => admin_url( $parent_page . '&page=' . $post_type . '-description' )
    4242            );
    4343            $admin_bar->add_menu( $args );
     
    4646    }
    4747
    48     if( is_admin() && isset( $_GET['page'] ) ) {
     48    /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */
     49    if ( is_admin() && isset( $_GET['page'] ) ) {
    4950
    50         $screen = get_current_screen();
    51         $post_type = ptad_get_post_type_from_admin_page_slug();
    52         $slug = $post_type . '-description';
     51        $screen = get_current_screen();
     52        $post_type = ptad_get_post_type_from_admin_page_slug();
     53        $slug = $post_type . '-description';
    5354        $base_ends_with_slug = substr_compare( $screen->base, $slug, strlen( $screen->base ) - strlen( $slug ), strlen( $slug ) );
    5455
    55         if( 0 === $base_ends_with_slug ) {
     56        if( 0 === $base_ends_with_slug ) {
    5657
    5758            $post_type_object = get_post_type_object( $post_type );
    58             $post_type_name = $post_type_object->labels->name;
     59            $post_type_name = $post_type_object->labels->name;
    5960
     61
    6062            $link_text = sprintf( __( 'View %1$s Archive', 'post-type-archive-descriptions' ), $post_type_name );
    6163
     
    7072                'id'    => 'wp-admin-bar-edit',
    7173                'title' => $link_text,
    72                 'href'  => get_post_type_archive_link( $post_type )
     74                'href'  => get_post_type_archive_link( $post_type )
    7375            );
    7476            $admin_bar->add_menu( $args );
     
    7779
    7880}
    79 add_action('admin_bar_menu', 'ptad_admin_bar_links',  100);
  • post-type-archive-descriptions/tags/1.5.0/inc/helpers.php

    r2745967 r2981804  
    11<?php
    2 /****************************************************
     2/**
     3 * Get post types that should use the Post Type Archive Description
    34 *
    4  * Get post types for plugin, filterable by users
     5 *
    56 *
    6  ****************************************************/
    7 /**
    8  * return array of post types that should use the Post Type Archive Description
    97 * @return array post types to use description with (default, all non-built-in with archive)
    108 */
    119function ptad_get_post_types() {
    1210
    13     $args = array(
    14         '_builtin' => false,
    15         'has_archive' => true
     11    $args = array(
     12        '_builtin' => false,
     13        'has_archive' => true
    1614    );
    1715    $post_types = apply_filters( 'ptad_post_types', get_post_types( $args ) );
     
    2119}
    2220
     21
     22
     23
    2324function ptad_get_post_type_from_admin_page_slug() {
    24     $page = $_GET['page'];
     25    /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */
     26    $page      = $_GET['page'];
    2527    $post_type = preg_replace( '/-description$/', '', $page );
    2628
     
    2830}
    2931
     32
     33
     34
    3035function ptad_get_post_type_from_queried_object() {
    3136    $queried_object = get_queried_object();
  • post-type-archive-descriptions/tags/1.5.0/inc/settings.php

    r2745967 r2981804  
    11<?php
    2 /****************************************************
    3  *
     2/**
    43 * Register Menu Pages, Settings, and Callbacks
    5  *
    6  ****************************************************/
     4 */
    75
    86add_action( 'admin_menu', 'ptad_enable_pages' );
     
    108 * Register admin pages for description field
    119 */
    12 
    1310function ptad_enable_pages() {
    1411
     
    1714    foreach ( $post_types as $post_type ) :
    1815
    19         if( post_type_exists( $post_type ) ) :
     16        if( post_type_exists( $post_type ) ) :
    2017
    2118            // Check if post type has a particular parent menu location
    2219            $post_type_object = get_post_type_object( $post_type );
    2320            $show_in_menu     = $post_type_object->show_in_menu;
    24            
     21
    2522            add_submenu_page(
    2623                ptad_settings_page_parent( $post_type, $show_in_menu ), // $parent slug
     
    3835}
    3936
     37
    4038/**
    4139 * Register Setting, Settings Section, and Settings Field
    4240 */
    43 
    44 add_action( 'admin_init', 'ptad_register_settings' );
    4541function ptad_register_settings() {
    4642
     
    5753    foreach ( $post_types as $post_type ) :
    5854
    59         if( post_type_exists( $post_type ) ) :
     55        if( post_type_exists( $post_type ) ) :
    6056
    6157            // Register settings and call sanitization functions
     
    7571                'ptad_settings_section_' . $post_type, // $section
    7672                array( // $args
    77                     'post_type' => $post_type,
     73                    'post_type' => $post_type,
    7874                    'field_name' => 'ptad_descriptions[' . $post_type . ']',
    79                     'label_for' => 'ptad_descriptions[' . $post_type . ']'
     75                    'label_for'
    8076                )
    8177            );
     
    9187
    9288    $post_type = str_replace( 'ptad_settings_section_', '', $args['id'] );
    93    
     89
    9490    /**
    9591     * Action before Description editor field in the admin
    9692     *
    97      * $post_type   slug of post type the description is for
     93     * $post_type slug of post type the description is for
    9894     */
    9995    do_action( 'ptad_before_editor', $post_type );
    100    
     96
    10197    /**
    10298     * Action before Description editor field in the admin only for a specific post type
     
    117113    $descriptions = (array) get_option( 'ptad_descriptions' );
    118114
    119     if( array_key_exists($post_type, $descriptions) ) {
    120         $description = $descriptions[$post_type];
     115    if) ) {
     116        $description = $descriptions[];
    121117    } else {
    122118        $description = '';
     
    127123        'textarea_rows' => 15,
    128124        'media_buttons' => true,
    129         'classes'       => 'wp-editor-area wp-editor'
     125        'classes'
    130126    );
    131127
     
    137133     * Action before Description editor field in the admin
    138134     *
    139      * $post_type   slug of post type the description is for
     135     * $post_type slug of post type the description is for
    140136     */
    141137    do_action( 'ptad_after_editor', $post_type );
    142    
     138
    143139    /**
    144140     * Action before Description editor field in the admin only for a specific post type
     
    147143     */
    148144    do_action( 'ptad_after_editor_' . $post_type );
    149    
     145
    150146    if ( ! defined( 'QTX_VERSION' ) ) {
    151147        add_filter( 'the_editor', 'qtranslate_admin_loadConfig' );
    152148    }
    153    
     149
    154150}
    155151
     
    160156
    161157    // occurs when parent menu item is not the post type
    162     if( empty( $post_type ) ) {
     158    if( empty( $post_type ) ) {
    163159        $post_type = ptad_get_post_type_from_admin_page_slug();
    164160    }
    165161    ?>
    166 
    167162    <div class="wrap">
    168         <h2><?php echo ptad_settings_page_title( $post_type, 'name' ); ?></h2>
     163        <h2><?php echo ); ?></h2>
    169164        <form action="options.php" method="POST">
    170165            <?php settings_fields( 'ptad_descriptions' ); ?>
     
    186181
    187182    // sanitize input
    188     foreach( $input as $post_type => $description ) {
    189         $sanitized_input[$post_type] = wp_kses_post( $description );
     183    foreach( $input as $post_type => $description ) {
     184        $sanitized_input[] = wp_kses_post( $description );
    190185    }
    191186
     
    199194/**
    200195 * Return capability that's allowed to edit posts
    201  * 
     196 *
    202197 * See: http://core.trac.wordpress.org/ticket/14365
    203198 */
     
    208203    /**
    209204     * filter the capability for who can edit descriptions
    210      * 
     205     *
    211206     * @param string $capability capability required to edit post type descriptions (default: edit_posts)
    212207     */
    213208    $capability = apply_filters( 'ptad_description_capability', $capability );
    214    
     209
    215210    return esc_attr( $capability );
    216211
     
    226221 */
    227222function ptad_settings_page_parent( $post_type, $show_in_menu = false ) {
    228  
     223
    229224    $settings_page_parent = $show_in_menu;
    230    
     225
    231226    // Default is standard post type editing screen
    232     if( $settings_page_parent && is_bool( $settings_page_parent ) ) {
     227    if( $settings_page_parent && is_bool( $settings_page_parent ) ) {
    233228        $settings_page_parent = "edit.php?post_type=$post_type";
    234229    }
    235    
     230
    236231    /**
    237232     * filter for parent of Archive Settings page
     
    248243/**
    249244 * Output filterable name of Settings page
    250  * 
     245 *
    251246 * @param string $post_type name of post type for the page
    252  * @param 'label'|'name' $pt_val whether $post_type is the label (default) or name
     247 * @param 'label'|'name' $p whether $post_type is the label (default) or name
    253248 * @return name for settings page
    254249 */
    255 function ptad_settings_page_title( $post_type, $pt_val = 'label' ) {
    256 
    257     if( $pt_val == 'name' ) {
     250function ptad_settings_page_title( $post_type, $p = 'label' ) {
     251
     252    if== 'name' ) {
    258253        $post_type_info = get_post_types( array( 'name' => $post_type ), 'objects' );
    259         $post_type = $post_type_info[$post_type]->labels->name;
    260     }
    261     $settings_page_title = sprintf( __( 'Description for the %1$s Archive', 'post-type-archive-descriptions' ), $post_type );
     254        $post_type      = $post_type_info[ $post_type ]->labels->name;
     255    }
     256    /* translators: %s: post type name */
     257    $settings_page_title = sprintf( __( 'Description for the %s Archive', 'post-type-archive-descriptions' ), $post_type );
    262258
    263259    /**
    264260     * filter for admin menu label
    265      * 
     261     *
    266262     * @param string $settings_page_menu_label label text (default: "Description for the {Post Type} Archive")
    267263     * @param string $post_type post_type name if needed
     
    276272 * Output filterable menu label for a post type's description settings page.
    277273 * @param  string $post_type post_type to create label for
    278  * @param 'label'|'name' $pt_val whether $post_type is the label (default) or name
     274 * @param 'label'|'name' $p whether $post_type is the label (default) or name
    279275 * @return string            admin menu label
    280276 */
    281 function ptad_settings_menu_label( $post_type, $pt_val = 'label' ) {
    282 
    283     if( $pt_val == 'name' ) {
     277function ptad_settings_menu_label( $post_type, $p = 'label' ) {
     278
     279    if== 'name' ) {
    284280        $post_type_info = get_post_types( array( 'name' => $post_type ), 'objects' );
    285         $post_type = $post_type_info[$post_type]->labels->name;
     281        $post_type ]->labels->name;
    286282    }
    287283
     
    290286    /**
    291287     * filter for admin menu label
    292      * 
     288     *
    293289     * @param string $settings_page_menu_label label text (default: "Description")
    294290     * @param string $post_type post_type name if needed
  • post-type-archive-descriptions/tags/1.5.0/inc/template-tags.php

    r2470184 r2981804  
    11<?php
    2 /****************************************************
    3  *
    4  * Functions to get Description Page Content
    5  *
    6  ****************************************************/
    72/**
    8  * echo post type archive description
    9  *
    10  * if on a post type archive, automatically grabs current post type
    11  *
     3 * Private/Legacy functions to get the description page content
     4 *
     5 * Developers: To display the archive description use get_the_archive_description() or the_archive_description().
     6 */
     7/**
     8 * Echo the post type archive description
     9 *
     10 * If on a post type archive, automatically grabs current post type
     11 *
    1212 * @param  string $post_type slug for post type to show description for (optional)
    1313 * @return string            post type description
     
    1818
    1919/**
    20  * return post type archive description
    21  * 
    22  * if on a post type archive, automatically grabs current post type
    23  * 
     20 * eturn post type archive description
     21 *
     22 * f on a post type archive, automatically grabs current post type
     23 *
    2424 * @param  string $post_type slug for post type to show description for (optional)
    2525 * @return string            post type description
    2626 */
    2727function ptad_get_post_type_description( $post_type = '' ) {
    28    
     28
    2929    // get global $post_type if not specified
    30     if ( '' == $post_type ) {
     30    if ( '' == $post_type ) {
    3131        $post_type = ptad_get_post_type_from_queried_object();
    3232    }
     
    3434    $all_descriptions = (array) get_option( 'ptad_descriptions' );
    3535
    36     if( array_key_exists($post_type, $all_descriptions) ) {
    37         $post_type_description = $all_descriptions[$post_type];
     36    if) ) {
     37        $post_type_description = $all_descriptions[];
    3838    } else {
    3939        $post_type_description = '';
    4040    }
    4141
     42
     43
    4244    $description = apply_filters( 'the_content', $post_type_description );
    4345
  • post-type-archive-descriptions/tags/1.5.0/post-type-archive-descriptions.php

    r2745967 r2981804  
    55Author: Mark Root-Wiley, MRW Web Design, NonprofitWP.org
    66Author URI: https://MRWweb.com
    7 Version: 1.4.0
     7Version: 1..0
    88License: GPL v3
    99Text Domain: post-type-archive-descriptions
     
    2626*/
    2727
    28 require_once( 'inc/helpers.php' );
    29 require_once( 'inc/settings.php' );
    30 require_once( 'inc/admin-bar.php' );
    31 require_once( 'inc/template-tags.php' );
     28require_once;
     29require_once;
     30require_once;
     31require_once;
    3232
    33 require_once( 'compat/wordpress-core.php' );
    34 require_once( 'compat/qtranslate-x.php' );
    35 require_once( 'compat/the-events-calendar.php' );
     33require_once;
     34require_once;
     35require_once;
  • post-type-archive-descriptions/tags/1.5.0/readme.txt

    r2745967 r2981804  
    66Tags: custom post type, custom post types, post type archive, archives, custom post type archive
    77Requires at least: 4.6
    8 Tested up to: 6.0
    9 Stable tag: 1.4.0
     8Tested up to: 6.
     9Stable tag: 1..0
    1010
    1111== Description ==
     
    110110
    111111== Changelog ==
     112
     113
     114
     115
     116
    112117= 1.4.0 (June 21, 2022) =
    113118* Tested up to 6.0.
     
    120125== Upgrade Notice ==
    121126= 1.4.0 =
    122 Tested up to WP 6.0. Restore missing "Edit Description" buttons in admin bar and description on The Events Calendar calendar page.
     127Tested up to WP 6..
  • post-type-archive-descriptions/trunk/changelog.txt

    r2745967 r2981804  
     1
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
    114= 1.3.1 (June 21, 2022) =
    215* Tested up to 6.0.
  • post-type-archive-descriptions/trunk/compat/qtranslate-x.php

    r2470184 r2981804  
    11<?php
    22/**
    3  * One additional line of compatability is in the `ptad_editor_field` function of the main plugin
     3 * One additional line of compatability is in the `ptad_editor_field` function of the main plugin
    44 */
    55if ( ! defined( 'QTX_VERSION' ) ) {
    66
    77    add_filter( 'ptad_wp_editor_settings', 'ptad_qtranslate_editor_args' );
    8 
    98    /**
    109     * filter editor settings to add necessary text editor classes for support
     
    1312     */
    1413    function ptad_qtranslate_editor_args( $editor_settings ) {
    15          $editor_settings['classes'] = $editor_settings['classes'] . ' multilanguage-input qtranxs-translatable';
     14        $editor_settings['classes'] = $editor_settings['classes'] . ' multilanguage-input qtranxs-translatable';
    1615
    17          return $editor_settings;
     16        return $editor_settings;
    1817    }
    19    
    20     add_filter('qtranslate_load_admin_page_config', 'ptad_qtranslate_support', 99); // 99 priority is important, loaded after registered post types
    2118
     19
     20
    2221    /**
    2322     * filter qtranslate so it knows to pay attention on archive description editor pages
     
    2524    function ptad_qtranslate_support( $page_configs ) {
    2625
    27         //edit.php?post_type=$post_type&page=
    2826        $page_config = array();
    29        
    30         //get post types
     27
     28        //get post types
    3129        $post_types = ptad_get_post_types();
    3230
     
    3432        foreach ( $post_types as $post_type ) {
    3533
    36             if( post_type_exists( $post_type ) ) {
     34            if( post_type_exists( $post_type ) ) {
    3735                $page_config['pages'] = array( 'edit.php' => 'post_type=' . $post_type . '&page=' );
    3836            }
    39            
    4037        }
    4138
     
    4542
    4643        $f['fields'] = array();
    47         $fields = &$f['fields'];
     44        $fields = &$f['fields'];
    4845
    4946        //textarea support
     
    5148
    5249        $page_config['forms'][] = $f;
    53         $page_configs[] = $page_config;
     50        $page_configs[] = $page_config;
    5451
    5552        return $page_configs;
    5653
    5754    }
    58 
    5955}
  • post-type-archive-descriptions/trunk/compat/the-events-calendar.php

    r2745967 r2981804  
    11<?php
     2
    23/**
    34 * Set the template which the Archive Description should appear before in v2 Tribe Events templates - OR - disable automatic output of archive description on Events templates with false
    45 */
    5 $before_template = apply_filters( 'ptad_tribe_template_before_include', 'events/v2/components/events-bar' );
    6 if( $before_template ) {
     6function ptad_tec_description() {
     7    $before_template = apply_filters(
     8        'ptad_tribe_template_before_include',
     9        'events/v2/components/before'
     10    );
     11    if ( $before_template ) {
    712
    8     add_action( 'tribe_template_before_include:' . esc_attr( $before_template ), 'ptad_tribe_events_archive_header' );
    9     /**
    10      * Add Title to Events Pages
    11      */
    12     function ptad_tribe_events_archive_header() {
    13 
    14         if( is_post_type_archive() && in_array( 'tribe_events', ptad_get_post_types() ) ) {
    15             the_archive_description( '<div class="archive-description">', '</div>' );
     13        add_action( 'tribe_template_before_include:' . esc_attr( $before_template ), 'ptad_tribe_events_archive_header' );
     14        /**
     15         * Add Title to Events Pages
     16         */
     17        function ptad_tribe_events_archive_header() {
     18            if (
     19                is_post_type_archive() &&
     20                in_array( 'tribe_events', ptad_get_post_types(), true )
     21            ) {
     22                the_archive_description( '<div class="archive-description">', '</div>' );
     23            }
    1624        }
    17 
    1825    }
    19 
    2026}
  • post-type-archive-descriptions/trunk/compat/wordpress-core.php

    r2470184 r2981804  
    11<?php
    2 /****************************************************
    3  *
    4  * Automatically display content if using *_archive_description() introduced in WordPress 4.1!
    5  *
    6  ****************************************************/
     2/**
     3 * Automatically display content if using get_archive_description() or the_archive_description() functions introduced in WordPress 4.1!
     4 */
    75add_filter( 'get_the_archive_description', 'ptad_archive_description' );
    86
     
    1311 */
    1412function ptad_archive_description( $description ) {
    15     if( is_post_type_archive( ptad_get_post_types() ) ) {
     13    if( is_post_type_archive( ptad_get_post_types() ) ) {
    1614        $description = ptad_get_post_type_description();
    1715    }
  • post-type-archive-descriptions/trunk/inc/admin-bar.php

    r2745967 r2981804  
    11<?php
    2 /****************************************************
    3  *
     2/**
    43 * Add Edit / View Links to the WordPress Admin Bar
    5  * 
     4 *
    65 * Props: blog.rutwick.com/add-items-anywhere-to-the-wp-3-3-admin-bar
    7  *
    8  ****************************************************/
     6 */
    97
     8
    109/**
    1110 * add links to view/edit archive in the admin bar
     
    1312function ptad_admin_bar_links( $admin_bar ) {
    1413
    15     if(
     14    if(
    1615        ! is_admin()
    1716        && is_post_type_archive( ptad_get_post_types() )
    1817        && current_user_can( ptad_allow_edit_posts() )
    19      ) {
    20         $post_type = ptad_get_post_type_from_queried_object();
     18    ) {
     19        $post_type = ptad_get_post_type_from_queried_object();
    2120        $post_type_object = get_post_type_object( $post_type );
    2221
    23         if( is_object( $post_type_object ) ) {
     22        if( is_object( $post_type_object ) ) {
    2423
    2524            $post_type_name = $post_type_object->labels->name;
    2625
    27             $link_text = sprintf( __( 'Edit %1$s Description', 'post-type-archive-descriptions' ), $post_type_name );
     26            /* translators: %s: post type name */
     27            $link_text = sprintf( __( 'Edit %s Description', 'post-type-archive-descriptions' ), $post_type_name );
    2828
    2929            /**
     
    3535
    3636            $parent_page = ptad_settings_page_parent( $post_type, $post_type_object->show_in_menu );
    37            
     37
    3838            $args = array(
    3939                'id'    => 'wp-admin-bar-edit',
    4040                'title' => $link_text,
    41                 'href'  => admin_url( $parent_page . '&page=' . $post_type . '-description' )
     41                'href'  => admin_url( $parent_page . '&page=' . $post_type . '-description' )
    4242            );
    4343            $admin_bar->add_menu( $args );
     
    4646    }
    4747
    48     if( is_admin() && isset( $_GET['page'] ) ) {
     48    /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */
     49    if ( is_admin() && isset( $_GET['page'] ) ) {
    4950
    50         $screen = get_current_screen();
    51         $post_type = ptad_get_post_type_from_admin_page_slug();
    52         $slug = $post_type . '-description';
     51        $screen = get_current_screen();
     52        $post_type = ptad_get_post_type_from_admin_page_slug();
     53        $slug = $post_type . '-description';
    5354        $base_ends_with_slug = substr_compare( $screen->base, $slug, strlen( $screen->base ) - strlen( $slug ), strlen( $slug ) );
    5455
    55         if( 0 === $base_ends_with_slug ) {
     56        if( 0 === $base_ends_with_slug ) {
    5657
    5758            $post_type_object = get_post_type_object( $post_type );
    58             $post_type_name = $post_type_object->labels->name;
     59            $post_type_name = $post_type_object->labels->name;
    5960
     61
    6062            $link_text = sprintf( __( 'View %1$s Archive', 'post-type-archive-descriptions' ), $post_type_name );
    6163
     
    7072                'id'    => 'wp-admin-bar-edit',
    7173                'title' => $link_text,
    72                 'href'  => get_post_type_archive_link( $post_type )
     74                'href'  => get_post_type_archive_link( $post_type )
    7375            );
    7476            $admin_bar->add_menu( $args );
     
    7779
    7880}
    79 add_action('admin_bar_menu', 'ptad_admin_bar_links',  100);
  • post-type-archive-descriptions/trunk/inc/helpers.php

    r2745967 r2981804  
    11<?php
    2 /****************************************************
     2/**
     3 * Get post types that should use the Post Type Archive Description
    34 *
    4  * Get post types for plugin, filterable by users
     5 *
    56 *
    6  ****************************************************/
    7 /**
    8  * return array of post types that should use the Post Type Archive Description
    97 * @return array post types to use description with (default, all non-built-in with archive)
    108 */
    119function ptad_get_post_types() {
    1210
    13     $args = array(
    14         '_builtin' => false,
    15         'has_archive' => true
     11    $args = array(
     12        '_builtin' => false,
     13        'has_archive' => true
    1614    );
    1715    $post_types = apply_filters( 'ptad_post_types', get_post_types( $args ) );
     
    2119}
    2220
     21
     22
     23
    2324function ptad_get_post_type_from_admin_page_slug() {
    24     $page = $_GET['page'];
     25    /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */
     26    $page      = $_GET['page'];
    2527    $post_type = preg_replace( '/-description$/', '', $page );
    2628
     
    2830}
    2931
     32
     33
     34
    3035function ptad_get_post_type_from_queried_object() {
    3136    $queried_object = get_queried_object();
  • post-type-archive-descriptions/trunk/inc/settings.php

    r2745967 r2981804  
    11<?php
    2 /****************************************************
    3  *
     2/**
    43 * Register Menu Pages, Settings, and Callbacks
    5  *
    6  ****************************************************/
     4 */
    75
    86add_action( 'admin_menu', 'ptad_enable_pages' );
     
    108 * Register admin pages for description field
    119 */
    12 
    1310function ptad_enable_pages() {
    1411
     
    1714    foreach ( $post_types as $post_type ) :
    1815
    19         if( post_type_exists( $post_type ) ) :
     16        if( post_type_exists( $post_type ) ) :
    2017
    2118            // Check if post type has a particular parent menu location
    2219            $post_type_object = get_post_type_object( $post_type );
    2320            $show_in_menu     = $post_type_object->show_in_menu;
    24            
     21
    2522            add_submenu_page(
    2623                ptad_settings_page_parent( $post_type, $show_in_menu ), // $parent slug
     
    3835}
    3936
     37
    4038/**
    4139 * Register Setting, Settings Section, and Settings Field
    4240 */
    43 
    44 add_action( 'admin_init', 'ptad_register_settings' );
    4541function ptad_register_settings() {
    4642
     
    5753    foreach ( $post_types as $post_type ) :
    5854
    59         if( post_type_exists( $post_type ) ) :
     55        if( post_type_exists( $post_type ) ) :
    6056
    6157            // Register settings and call sanitization functions
     
    7571                'ptad_settings_section_' . $post_type, // $section
    7672                array( // $args
    77                     'post_type' => $post_type,
     73                    'post_type' => $post_type,
    7874                    'field_name' => 'ptad_descriptions[' . $post_type . ']',
    79                     'label_for' => 'ptad_descriptions[' . $post_type . ']'
     75                    'label_for'
    8076                )
    8177            );
     
    9187
    9288    $post_type = str_replace( 'ptad_settings_section_', '', $args['id'] );
    93    
     89
    9490    /**
    9591     * Action before Description editor field in the admin
    9692     *
    97      * $post_type   slug of post type the description is for
     93     * $post_type slug of post type the description is for
    9894     */
    9995    do_action( 'ptad_before_editor', $post_type );
    100    
     96
    10197    /**
    10298     * Action before Description editor field in the admin only for a specific post type
     
    117113    $descriptions = (array) get_option( 'ptad_descriptions' );
    118114
    119     if( array_key_exists($post_type, $descriptions) ) {
    120         $description = $descriptions[$post_type];
     115    if) ) {
     116        $description = $descriptions[];
    121117    } else {
    122118        $description = '';
     
    127123        'textarea_rows' => 15,
    128124        'media_buttons' => true,
    129         'classes'       => 'wp-editor-area wp-editor'
     125        'classes'
    130126    );
    131127
     
    137133     * Action before Description editor field in the admin
    138134     *
    139      * $post_type   slug of post type the description is for
     135     * $post_type slug of post type the description is for
    140136     */
    141137    do_action( 'ptad_after_editor', $post_type );
    142    
     138
    143139    /**
    144140     * Action before Description editor field in the admin only for a specific post type
     
    147143     */
    148144    do_action( 'ptad_after_editor_' . $post_type );
    149    
     145
    150146    if ( ! defined( 'QTX_VERSION' ) ) {
    151147        add_filter( 'the_editor', 'qtranslate_admin_loadConfig' );
    152148    }
    153    
     149
    154150}
    155151
     
    160156
    161157    // occurs when parent menu item is not the post type
    162     if( empty( $post_type ) ) {
     158    if( empty( $post_type ) ) {
    163159        $post_type = ptad_get_post_type_from_admin_page_slug();
    164160    }
    165161    ?>
    166 
    167162    <div class="wrap">
    168         <h2><?php echo ptad_settings_page_title( $post_type, 'name' ); ?></h2>
     163        <h2><?php echo ); ?></h2>
    169164        <form action="options.php" method="POST">
    170165            <?php settings_fields( 'ptad_descriptions' ); ?>
     
    186181
    187182    // sanitize input
    188     foreach( $input as $post_type => $description ) {
    189         $sanitized_input[$post_type] = wp_kses_post( $description );
     183    foreach( $input as $post_type => $description ) {
     184        $sanitized_input[] = wp_kses_post( $description );
    190185    }
    191186
     
    199194/**
    200195 * Return capability that's allowed to edit posts
    201  * 
     196 *
    202197 * See: http://core.trac.wordpress.org/ticket/14365
    203198 */
     
    208203    /**
    209204     * filter the capability for who can edit descriptions
    210      * 
     205     *
    211206     * @param string $capability capability required to edit post type descriptions (default: edit_posts)
    212207     */
    213208    $capability = apply_filters( 'ptad_description_capability', $capability );
    214    
     209
    215210    return esc_attr( $capability );
    216211
     
    226221 */
    227222function ptad_settings_page_parent( $post_type, $show_in_menu = false ) {
    228  
     223
    229224    $settings_page_parent = $show_in_menu;
    230    
     225
    231226    // Default is standard post type editing screen
    232     if( $settings_page_parent && is_bool( $settings_page_parent ) ) {
     227    if( $settings_page_parent && is_bool( $settings_page_parent ) ) {
    233228        $settings_page_parent = "edit.php?post_type=$post_type";
    234229    }
    235    
     230
    236231    /**
    237232     * filter for parent of Archive Settings page
     
    248243/**
    249244 * Output filterable name of Settings page
    250  * 
     245 *
    251246 * @param string $post_type name of post type for the page
    252  * @param 'label'|'name' $pt_val whether $post_type is the label (default) or name
     247 * @param 'label'|'name' $p whether $post_type is the label (default) or name
    253248 * @return name for settings page
    254249 */
    255 function ptad_settings_page_title( $post_type, $pt_val = 'label' ) {
    256 
    257     if( $pt_val == 'name' ) {
     250function ptad_settings_page_title( $post_type, $p = 'label' ) {
     251
     252    if== 'name' ) {
    258253        $post_type_info = get_post_types( array( 'name' => $post_type ), 'objects' );
    259         $post_type = $post_type_info[$post_type]->labels->name;
    260     }
    261     $settings_page_title = sprintf( __( 'Description for the %1$s Archive', 'post-type-archive-descriptions' ), $post_type );
     254        $post_type      = $post_type_info[ $post_type ]->labels->name;
     255    }
     256    /* translators: %s: post type name */
     257    $settings_page_title = sprintf( __( 'Description for the %s Archive', 'post-type-archive-descriptions' ), $post_type );
    262258
    263259    /**
    264260     * filter for admin menu label
    265      * 
     261     *
    266262     * @param string $settings_page_menu_label label text (default: "Description for the {Post Type} Archive")
    267263     * @param string $post_type post_type name if needed
     
    276272 * Output filterable menu label for a post type's description settings page.
    277273 * @param  string $post_type post_type to create label for
    278  * @param 'label'|'name' $pt_val whether $post_type is the label (default) or name
     274 * @param 'label'|'name' $p whether $post_type is the label (default) or name
    279275 * @return string            admin menu label
    280276 */
    281 function ptad_settings_menu_label( $post_type, $pt_val = 'label' ) {
    282 
    283     if( $pt_val == 'name' ) {
     277function ptad_settings_menu_label( $post_type, $p = 'label' ) {
     278
     279    if== 'name' ) {
    284280        $post_type_info = get_post_types( array( 'name' => $post_type ), 'objects' );
    285         $post_type = $post_type_info[$post_type]->labels->name;
     281        $post_type ]->labels->name;
    286282    }
    287283
     
    290286    /**
    291287     * filter for admin menu label
    292      * 
     288     *
    293289     * @param string $settings_page_menu_label label text (default: "Description")
    294290     * @param string $post_type post_type name if needed
  • post-type-archive-descriptions/trunk/inc/template-tags.php

    r2470184 r2981804  
    11<?php
    2 /****************************************************
    3  *
    4  * Functions to get Description Page Content
    5  *
    6  ****************************************************/
    72/**
    8  * echo post type archive description
    9  *
    10  * if on a post type archive, automatically grabs current post type
    11  *
     3 * Private/Legacy functions to get the description page content
     4 *
     5 * Developers: To display the archive description use get_the_archive_description() or the_archive_description().
     6 */
     7/**
     8 * Echo the post type archive description
     9 *
     10 * If on a post type archive, automatically grabs current post type
     11 *
    1212 * @param  string $post_type slug for post type to show description for (optional)
    1313 * @return string            post type description
     
    1818
    1919/**
    20  * return post type archive description
    21  * 
    22  * if on a post type archive, automatically grabs current post type
    23  * 
     20 * eturn post type archive description
     21 *
     22 * f on a post type archive, automatically grabs current post type
     23 *
    2424 * @param  string $post_type slug for post type to show description for (optional)
    2525 * @return string            post type description
    2626 */
    2727function ptad_get_post_type_description( $post_type = '' ) {
    28    
     28
    2929    // get global $post_type if not specified
    30     if ( '' == $post_type ) {
     30    if ( '' == $post_type ) {
    3131        $post_type = ptad_get_post_type_from_queried_object();
    3232    }
     
    3434    $all_descriptions = (array) get_option( 'ptad_descriptions' );
    3535
    36     if( array_key_exists($post_type, $all_descriptions) ) {
    37         $post_type_description = $all_descriptions[$post_type];
     36    if) ) {
     37        $post_type_description = $all_descriptions[];
    3838    } else {
    3939        $post_type_description = '';
    4040    }
    4141
     42
     43
    4244    $description = apply_filters( 'the_content', $post_type_description );
    4345
  • post-type-archive-descriptions/trunk/post-type-archive-descriptions.php

    r2745967 r2981804  
    55Author: Mark Root-Wiley, MRW Web Design, NonprofitWP.org
    66Author URI: https://MRWweb.com
    7 Version: 1.4.0
     7Version: 1..0
    88License: GPL v3
    99Text Domain: post-type-archive-descriptions
     
    2626*/
    2727
    28 require_once( 'inc/helpers.php' );
    29 require_once( 'inc/settings.php' );
    30 require_once( 'inc/admin-bar.php' );
    31 require_once( 'inc/template-tags.php' );
     28require_once;
     29require_once;
     30require_once;
     31require_once;
    3232
    33 require_once( 'compat/wordpress-core.php' );
    34 require_once( 'compat/qtranslate-x.php' );
    35 require_once( 'compat/the-events-calendar.php' );
     33require_once;
     34require_once;
     35require_once;
  • post-type-archive-descriptions/trunk/readme.txt

    r2745967 r2981804  
    66Tags: custom post type, custom post types, post type archive, archives, custom post type archive
    77Requires at least: 4.6
    8 Tested up to: 6.0
    9 Stable tag: 1.4.0
     8Tested up to: 6.
     9Stable tag: 1..0
    1010
    1111== Description ==
     
    110110
    111111== Changelog ==
     112
     113
     114
     115
     116
    112117= 1.4.0 (June 21, 2022) =
    113118* Tested up to 6.0.
     
    120125== Upgrade Notice ==
    121126= 1.4.0 =
    122 Tested up to WP 6.0. Restore missing "Edit Description" buttons in admin bar and description on The Events Calendar calendar page.
     127Tested up to WP 6..
Note: See TracChangeset for help on using the changeset viewer.