Changeset 2981804
- Timestamp:
- 10/20/2023 05:14:28 PM (10 months ago)
- 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
-
Property
svn:mime-type
set to
-
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 1 14 = 1.3.1 (June 21, 2022) = 2 15 * Tested up to 6.0. -
post-type-archive-descriptions/tags/1.5.0/compat/qtranslate-x.php
r2470184 r2981804 1 1 <?php 2 2 /** 3 * One additional line of compatability is in the `ptad_editor_field` function of the main plugin3 * One additional line of compatability is in the `ptad_editor_field` function of the main plugin 4 4 */ 5 5 if ( ! defined( 'QTX_VERSION' ) ) { 6 6 7 7 add_filter( 'ptad_wp_editor_settings', 'ptad_qtranslate_editor_args' ); 8 9 8 /** 10 9 * filter editor settings to add necessary text editor classes for support … … 13 12 */ 14 13 function ptad_qtranslate_editor_args( $editor_settings ) { 15 14 $editor_settings['classes'] = $editor_settings['classes'] . ' multilanguage-input qtranxs-translatable'; 16 15 17 16 return $editor_settings; 18 17 } 19 20 add_filter('qtranslate_load_admin_page_config', 'ptad_qtranslate_support', 99); // 99 priority is important, loaded after registered post types21 18 19 20 22 21 /** 23 22 * filter qtranslate so it knows to pay attention on archive description editor pages … … 25 24 function ptad_qtranslate_support( $page_configs ) { 26 25 27 //edit.php?post_type=$post_type&page=28 26 $page_config = array(); 29 30 // get post types27 28 //get post types 31 29 $post_types = ptad_get_post_types(); 32 30 … … 34 32 foreach ( $post_types as $post_type ) { 35 33 36 if ( post_type_exists( $post_type ) ) {34 if( post_type_exists( $post_type ) ) { 37 35 $page_config['pages'] = array( 'edit.php' => 'post_type=' . $post_type . '&page=' ); 38 36 } 39 40 37 } 41 38 … … 45 42 46 43 $f['fields'] = array(); 47 $fields = &$f['fields'];44 $fields = &$f['fields']; 48 45 49 46 //textarea support … … 51 48 52 49 $page_config['forms'][] = $f; 53 $page_configs[] = $page_config;50 $page_configs[] = $page_config; 54 51 55 52 return $page_configs; 56 53 57 54 } 58 59 55 } -
post-type-archive-descriptions/tags/1.5.0/compat/the-events-calendar.php
r2745967 r2981804 1 1 <?php 2 2 3 /** 3 4 * 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 4 5 */ 5 $before_template = apply_filters( 'ptad_tribe_template_before_include', 'events/v2/components/events-bar' ); 6 if( $before_template ) { 6 function ptad_tec_description() { 7 $before_template = apply_filters( 8 'ptad_tribe_template_before_include', 9 'events/v2/components/before' 10 ); 11 if ( $before_template ) { 7 12 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 } 16 24 } 17 18 25 } 19 20 26 } -
post-type-archive-descriptions/tags/1.5.0/compat/wordpress-core.php
r2470184 r2981804 1 1 <?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 */ 7 5 add_filter( 'get_the_archive_description', 'ptad_archive_description' ); 8 6 … … 13 11 */ 14 12 function ptad_archive_description( $description ) { 15 if ( is_post_type_archive( ptad_get_post_types() ) ) {13 if( is_post_type_archive( ptad_get_post_types() ) ) { 16 14 $description = ptad_get_post_type_description(); 17 15 } -
post-type-archive-descriptions/tags/1.5.0/inc/admin-bar.php
r2745967 r2981804 1 1 <?php 2 /**************************************************** 3 * 2 /** 4 3 * Add Edit / View Links to the WordPress Admin Bar 5 * 4 * 6 5 * Props: blog.rutwick.com/add-items-anywhere-to-the-wp-3-3-admin-bar 7 * 8 ****************************************************/ 6 */ 9 7 8 10 9 /** 11 10 * add links to view/edit archive in the admin bar … … 13 12 function ptad_admin_bar_links( $admin_bar ) { 14 13 15 if (14 if( 16 15 ! is_admin() 17 16 && is_post_type_archive( ptad_get_post_types() ) 18 17 && 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(); 21 20 $post_type_object = get_post_type_object( $post_type ); 22 21 23 if ( is_object( $post_type_object ) ) {22 if( is_object( $post_type_object ) ) { 24 23 25 24 $post_type_name = $post_type_object->labels->name; 26 25 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 ); 28 28 29 29 /** … … 35 35 36 36 $parent_page = ptad_settings_page_parent( $post_type, $post_type_object->show_in_menu ); 37 37 38 38 $args = array( 39 39 'id' => 'wp-admin-bar-edit', 40 40 'title' => $link_text, 41 'href' => admin_url( $parent_page . '&page=' . $post_type . '-description' ) 41 'href' => admin_url( $parent_page . '&page=' . $post_type . '-description' ) 42 42 ); 43 43 $admin_bar->add_menu( $args ); … … 46 46 } 47 47 48 if( is_admin() && isset( $_GET['page'] ) ) { 48 /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ 49 if ( is_admin() && isset( $_GET['page'] ) ) { 49 50 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'; 53 54 $base_ends_with_slug = substr_compare( $screen->base, $slug, strlen( $screen->base ) - strlen( $slug ), strlen( $slug ) ); 54 55 55 if ( 0 === $base_ends_with_slug ) {56 if( 0 === $base_ends_with_slug ) { 56 57 57 58 $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; 59 60 61 60 62 $link_text = sprintf( __( 'View %1$s Archive', 'post-type-archive-descriptions' ), $post_type_name ); 61 63 … … 70 72 'id' => 'wp-admin-bar-edit', 71 73 'title' => $link_text, 72 'href' => get_post_type_archive_link( $post_type ) 74 'href' => get_post_type_archive_link( $post_type ) 73 75 ); 74 76 $admin_bar->add_menu( $args ); … … 77 79 78 80 } 79 add_action('admin_bar_menu', 'ptad_admin_bar_links', 100); -
post-type-archive-descriptions/tags/1.5.0/inc/helpers.php
r2745967 r2981804 1 1 <?php 2 /**************************************************** 2 /** 3 * Get post types that should use the Post Type Archive Description 3 4 * 4 * Get post types for plugin, filterable by users5 * 5 6 * 6 ****************************************************/7 /**8 * return array of post types that should use the Post Type Archive Description9 7 * @return array post types to use description with (default, all non-built-in with archive) 10 8 */ 11 9 function ptad_get_post_types() { 12 10 13 $args = array(14 '_builtin' => false,15 'has_archive' => true 11 $args = array( 12 '_builtin' => false, 13 'has_archive' => true 16 14 ); 17 15 $post_types = apply_filters( 'ptad_post_types', get_post_types( $args ) ); … … 21 19 } 22 20 21 22 23 23 24 function ptad_get_post_type_from_admin_page_slug() { 24 $page = $_GET['page']; 25 /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ 26 $page = $_GET['page']; 25 27 $post_type = preg_replace( '/-description$/', '', $page ); 26 28 … … 28 30 } 29 31 32 33 34 30 35 function ptad_get_post_type_from_queried_object() { 31 36 $queried_object = get_queried_object(); -
post-type-archive-descriptions/tags/1.5.0/inc/settings.php
r2745967 r2981804 1 1 <?php 2 /**************************************************** 3 * 2 /** 4 3 * Register Menu Pages, Settings, and Callbacks 5 * 6 ****************************************************/ 4 */ 7 5 8 6 add_action( 'admin_menu', 'ptad_enable_pages' ); … … 10 8 * Register admin pages for description field 11 9 */ 12 13 10 function ptad_enable_pages() { 14 11 … … 17 14 foreach ( $post_types as $post_type ) : 18 15 19 if ( post_type_exists( $post_type ) ) :16 if( post_type_exists( $post_type ) ) : 20 17 21 18 // Check if post type has a particular parent menu location 22 19 $post_type_object = get_post_type_object( $post_type ); 23 20 $show_in_menu = $post_type_object->show_in_menu; 24 21 25 22 add_submenu_page( 26 23 ptad_settings_page_parent( $post_type, $show_in_menu ), // $parent slug … … 38 35 } 39 36 37 40 38 /** 41 39 * Register Setting, Settings Section, and Settings Field 42 40 */ 43 44 add_action( 'admin_init', 'ptad_register_settings' );45 41 function ptad_register_settings() { 46 42 … … 57 53 foreach ( $post_types as $post_type ) : 58 54 59 if ( post_type_exists( $post_type ) ) :55 if( post_type_exists( $post_type ) ) : 60 56 61 57 // Register settings and call sanitization functions … … 75 71 'ptad_settings_section_' . $post_type, // $section 76 72 array( // $args 77 'post_type' => $post_type,73 'post_type' => $post_type, 78 74 'field_name' => 'ptad_descriptions[' . $post_type . ']', 79 'label_for' => 'ptad_descriptions[' . $post_type . ']'75 'label_for' 80 76 ) 81 77 ); … … 91 87 92 88 $post_type = str_replace( 'ptad_settings_section_', '', $args['id'] ); 93 89 94 90 /** 95 91 * Action before Description editor field in the admin 96 92 * 97 * $post_type 93 * $post_type slug of post type the description is for 98 94 */ 99 95 do_action( 'ptad_before_editor', $post_type ); 100 96 101 97 /** 102 98 * Action before Description editor field in the admin only for a specific post type … … 117 113 $descriptions = (array) get_option( 'ptad_descriptions' ); 118 114 119 if ( array_key_exists($post_type, $descriptions) ) {120 $description = $descriptions[ $post_type];115 if) ) { 116 $description = $descriptions[]; 121 117 } else { 122 118 $description = ''; … … 127 123 'textarea_rows' => 15, 128 124 'media_buttons' => true, 129 'classes' => 'wp-editor-area wp-editor'125 'classes' 130 126 ); 131 127 … … 137 133 * Action before Description editor field in the admin 138 134 * 139 * $post_type 135 * $post_type slug of post type the description is for 140 136 */ 141 137 do_action( 'ptad_after_editor', $post_type ); 142 138 143 139 /** 144 140 * Action before Description editor field in the admin only for a specific post type … … 147 143 */ 148 144 do_action( 'ptad_after_editor_' . $post_type ); 149 145 150 146 if ( ! defined( 'QTX_VERSION' ) ) { 151 147 add_filter( 'the_editor', 'qtranslate_admin_loadConfig' ); 152 148 } 153 149 154 150 } 155 151 … … 160 156 161 157 // occurs when parent menu item is not the post type 162 if ( empty( $post_type ) ) {158 if( empty( $post_type ) ) { 163 159 $post_type = ptad_get_post_type_from_admin_page_slug(); 164 160 } 165 161 ?> 166 167 162 <div class="wrap"> 168 <h2><?php echo ptad_settings_page_title( $post_type, 'name'); ?></h2>163 <h2><?php echo ); ?></h2> 169 164 <form action="options.php" method="POST"> 170 165 <?php settings_fields( 'ptad_descriptions' ); ?> … … 186 181 187 182 // 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 ); 190 185 } 191 186 … … 199 194 /** 200 195 * Return capability that's allowed to edit posts 201 * 196 * 202 197 * See: http://core.trac.wordpress.org/ticket/14365 203 198 */ … … 208 203 /** 209 204 * filter the capability for who can edit descriptions 210 * 205 * 211 206 * @param string $capability capability required to edit post type descriptions (default: edit_posts) 212 207 */ 213 208 $capability = apply_filters( 'ptad_description_capability', $capability ); 214 209 215 210 return esc_attr( $capability ); 216 211 … … 226 221 */ 227 222 function ptad_settings_page_parent( $post_type, $show_in_menu = false ) { 228 223 229 224 $settings_page_parent = $show_in_menu; 230 225 231 226 // 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 ) ) { 233 228 $settings_page_parent = "edit.php?post_type=$post_type"; 234 229 } 235 230 236 231 /** 237 232 * filter for parent of Archive Settings page … … 248 243 /** 249 244 * Output filterable name of Settings page 250 * 245 * 251 246 * @param string $post_type name of post type for the page 252 * @param 'label'|'name' $p t_valwhether $post_type is the label (default) or name247 * @param 'label'|'name' $p whether $post_type is the label (default) or name 253 248 * @return name for settings page 254 249 */ 255 function ptad_settings_page_title( $post_type, $p t_val= 'label' ) {256 257 if ( $pt_val== 'name' ) {250 function ptad_settings_page_title( $post_type, $p = 'label' ) { 251 252 if== 'name' ) { 258 253 $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 ); 262 258 263 259 /** 264 260 * filter for admin menu label 265 * 261 * 266 262 * @param string $settings_page_menu_label label text (default: "Description for the {Post Type} Archive") 267 263 * @param string $post_type post_type name if needed … … 276 272 * Output filterable menu label for a post type's description settings page. 277 273 * @param string $post_type post_type to create label for 278 * @param 'label'|'name' $p t_valwhether $post_type is the label (default) or name274 * @param 'label'|'name' $p whether $post_type is the label (default) or name 279 275 * @return string admin menu label 280 276 */ 281 function ptad_settings_menu_label( $post_type, $p t_val= 'label' ) {282 283 if ( $pt_val== 'name' ) {277 function ptad_settings_menu_label( $post_type, $p = 'label' ) { 278 279 if== 'name' ) { 284 280 $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; 286 282 } 287 283 … … 290 286 /** 291 287 * filter for admin menu label 292 * 288 * 293 289 * @param string $settings_page_menu_label label text (default: "Description") 294 290 * @param string $post_type post_type name if needed -
post-type-archive-descriptions/tags/1.5.0/inc/template-tags.php
r2470184 r2981804 1 1 <?php 2 /****************************************************3 *4 * Functions to get Description Page Content5 *6 ****************************************************/7 2 /** 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 * 12 12 * @param string $post_type slug for post type to show description for (optional) 13 13 * @return string post type description … … 18 18 19 19 /** 20 * return post type archive description21 * 22 * if on a post type archive, automatically grabs current post type23 * 20 * eturn post type archive description 21 * 22 * f on a post type archive, automatically grabs current post type 23 * 24 24 * @param string $post_type slug for post type to show description for (optional) 25 25 * @return string post type description 26 26 */ 27 27 function ptad_get_post_type_description( $post_type = '' ) { 28 28 29 29 // get global $post_type if not specified 30 if ( '' == $post_type ) {30 if ( '' == $post_type ) { 31 31 $post_type = ptad_get_post_type_from_queried_object(); 32 32 } … … 34 34 $all_descriptions = (array) get_option( 'ptad_descriptions' ); 35 35 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[]; 38 38 } else { 39 39 $post_type_description = ''; 40 40 } 41 41 42 43 42 44 $description = apply_filters( 'the_content', $post_type_description ); 43 45 -
post-type-archive-descriptions/tags/1.5.0/post-type-archive-descriptions.php
r2745967 r2981804 5 5 Author: Mark Root-Wiley, MRW Web Design, NonprofitWP.org 6 6 Author URI: https://MRWweb.com 7 Version: 1. 4.07 Version: 1..0 8 8 License: GPL v3 9 9 Text Domain: post-type-archive-descriptions … … 26 26 */ 27 27 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' );28 require_once; 29 require_once; 30 require_once; 31 require_once; 32 32 33 require_once ( 'compat/wordpress-core.php' );34 require_once ( 'compat/qtranslate-x.php' );35 require_once ( 'compat/the-events-calendar.php' );33 require_once; 34 require_once; 35 require_once; -
post-type-archive-descriptions/tags/1.5.0/readme.txt
r2745967 r2981804 6 6 Tags: custom post type, custom post types, post type archive, archives, custom post type archive 7 7 Requires at least: 4.6 8 Tested up to: 6. 09 Stable tag: 1. 4.08 Tested up to: 6. 9 Stable tag: 1..0 10 10 11 11 == Description == … … 110 110 111 111 == Changelog == 112 113 114 115 116 112 117 = 1.4.0 (June 21, 2022) = 113 118 * Tested up to 6.0. … … 120 125 == Upgrade Notice == 121 126 = 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.127 Tested 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 1 14 = 1.3.1 (June 21, 2022) = 2 15 * Tested up to 6.0. -
post-type-archive-descriptions/trunk/compat/qtranslate-x.php
r2470184 r2981804 1 1 <?php 2 2 /** 3 * One additional line of compatability is in the `ptad_editor_field` function of the main plugin3 * One additional line of compatability is in the `ptad_editor_field` function of the main plugin 4 4 */ 5 5 if ( ! defined( 'QTX_VERSION' ) ) { 6 6 7 7 add_filter( 'ptad_wp_editor_settings', 'ptad_qtranslate_editor_args' ); 8 9 8 /** 10 9 * filter editor settings to add necessary text editor classes for support … … 13 12 */ 14 13 function ptad_qtranslate_editor_args( $editor_settings ) { 15 14 $editor_settings['classes'] = $editor_settings['classes'] . ' multilanguage-input qtranxs-translatable'; 16 15 17 16 return $editor_settings; 18 17 } 19 20 add_filter('qtranslate_load_admin_page_config', 'ptad_qtranslate_support', 99); // 99 priority is important, loaded after registered post types21 18 19 20 22 21 /** 23 22 * filter qtranslate so it knows to pay attention on archive description editor pages … … 25 24 function ptad_qtranslate_support( $page_configs ) { 26 25 27 //edit.php?post_type=$post_type&page=28 26 $page_config = array(); 29 30 // get post types27 28 //get post types 31 29 $post_types = ptad_get_post_types(); 32 30 … … 34 32 foreach ( $post_types as $post_type ) { 35 33 36 if ( post_type_exists( $post_type ) ) {34 if( post_type_exists( $post_type ) ) { 37 35 $page_config['pages'] = array( 'edit.php' => 'post_type=' . $post_type . '&page=' ); 38 36 } 39 40 37 } 41 38 … … 45 42 46 43 $f['fields'] = array(); 47 $fields = &$f['fields'];44 $fields = &$f['fields']; 48 45 49 46 //textarea support … … 51 48 52 49 $page_config['forms'][] = $f; 53 $page_configs[] = $page_config;50 $page_configs[] = $page_config; 54 51 55 52 return $page_configs; 56 53 57 54 } 58 59 55 } -
post-type-archive-descriptions/trunk/compat/the-events-calendar.php
r2745967 r2981804 1 1 <?php 2 2 3 /** 3 4 * 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 4 5 */ 5 $before_template = apply_filters( 'ptad_tribe_template_before_include', 'events/v2/components/events-bar' ); 6 if( $before_template ) { 6 function ptad_tec_description() { 7 $before_template = apply_filters( 8 'ptad_tribe_template_before_include', 9 'events/v2/components/before' 10 ); 11 if ( $before_template ) { 7 12 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 } 16 24 } 17 18 25 } 19 20 26 } -
post-type-archive-descriptions/trunk/compat/wordpress-core.php
r2470184 r2981804 1 1 <?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 */ 7 5 add_filter( 'get_the_archive_description', 'ptad_archive_description' ); 8 6 … … 13 11 */ 14 12 function ptad_archive_description( $description ) { 15 if ( is_post_type_archive( ptad_get_post_types() ) ) {13 if( is_post_type_archive( ptad_get_post_types() ) ) { 16 14 $description = ptad_get_post_type_description(); 17 15 } -
post-type-archive-descriptions/trunk/inc/admin-bar.php
r2745967 r2981804 1 1 <?php 2 /**************************************************** 3 * 2 /** 4 3 * Add Edit / View Links to the WordPress Admin Bar 5 * 4 * 6 5 * Props: blog.rutwick.com/add-items-anywhere-to-the-wp-3-3-admin-bar 7 * 8 ****************************************************/ 6 */ 9 7 8 10 9 /** 11 10 * add links to view/edit archive in the admin bar … … 13 12 function ptad_admin_bar_links( $admin_bar ) { 14 13 15 if (14 if( 16 15 ! is_admin() 17 16 && is_post_type_archive( ptad_get_post_types() ) 18 17 && 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(); 21 20 $post_type_object = get_post_type_object( $post_type ); 22 21 23 if ( is_object( $post_type_object ) ) {22 if( is_object( $post_type_object ) ) { 24 23 25 24 $post_type_name = $post_type_object->labels->name; 26 25 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 ); 28 28 29 29 /** … … 35 35 36 36 $parent_page = ptad_settings_page_parent( $post_type, $post_type_object->show_in_menu ); 37 37 38 38 $args = array( 39 39 'id' => 'wp-admin-bar-edit', 40 40 'title' => $link_text, 41 'href' => admin_url( $parent_page . '&page=' . $post_type . '-description' ) 41 'href' => admin_url( $parent_page . '&page=' . $post_type . '-description' ) 42 42 ); 43 43 $admin_bar->add_menu( $args ); … … 46 46 } 47 47 48 if( is_admin() && isset( $_GET['page'] ) ) { 48 /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ 49 if ( is_admin() && isset( $_GET['page'] ) ) { 49 50 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'; 53 54 $base_ends_with_slug = substr_compare( $screen->base, $slug, strlen( $screen->base ) - strlen( $slug ), strlen( $slug ) ); 54 55 55 if ( 0 === $base_ends_with_slug ) {56 if( 0 === $base_ends_with_slug ) { 56 57 57 58 $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; 59 60 61 60 62 $link_text = sprintf( __( 'View %1$s Archive', 'post-type-archive-descriptions' ), $post_type_name ); 61 63 … … 70 72 'id' => 'wp-admin-bar-edit', 71 73 'title' => $link_text, 72 'href' => get_post_type_archive_link( $post_type ) 74 'href' => get_post_type_archive_link( $post_type ) 73 75 ); 74 76 $admin_bar->add_menu( $args ); … … 77 79 78 80 } 79 add_action('admin_bar_menu', 'ptad_admin_bar_links', 100); -
post-type-archive-descriptions/trunk/inc/helpers.php
r2745967 r2981804 1 1 <?php 2 /**************************************************** 2 /** 3 * Get post types that should use the Post Type Archive Description 3 4 * 4 * Get post types for plugin, filterable by users5 * 5 6 * 6 ****************************************************/7 /**8 * return array of post types that should use the Post Type Archive Description9 7 * @return array post types to use description with (default, all non-built-in with archive) 10 8 */ 11 9 function ptad_get_post_types() { 12 10 13 $args = array(14 '_builtin' => false,15 'has_archive' => true 11 $args = array( 12 '_builtin' => false, 13 'has_archive' => true 16 14 ); 17 15 $post_types = apply_filters( 'ptad_post_types', get_post_types( $args ) ); … … 21 19 } 22 20 21 22 23 23 24 function ptad_get_post_type_from_admin_page_slug() { 24 $page = $_GET['page']; 25 /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ 26 $page = $_GET['page']; 25 27 $post_type = preg_replace( '/-description$/', '', $page ); 26 28 … … 28 30 } 29 31 32 33 34 30 35 function ptad_get_post_type_from_queried_object() { 31 36 $queried_object = get_queried_object(); -
post-type-archive-descriptions/trunk/inc/settings.php
r2745967 r2981804 1 1 <?php 2 /**************************************************** 3 * 2 /** 4 3 * Register Menu Pages, Settings, and Callbacks 5 * 6 ****************************************************/ 4 */ 7 5 8 6 add_action( 'admin_menu', 'ptad_enable_pages' ); … … 10 8 * Register admin pages for description field 11 9 */ 12 13 10 function ptad_enable_pages() { 14 11 … … 17 14 foreach ( $post_types as $post_type ) : 18 15 19 if ( post_type_exists( $post_type ) ) :16 if( post_type_exists( $post_type ) ) : 20 17 21 18 // Check if post type has a particular parent menu location 22 19 $post_type_object = get_post_type_object( $post_type ); 23 20 $show_in_menu = $post_type_object->show_in_menu; 24 21 25 22 add_submenu_page( 26 23 ptad_settings_page_parent( $post_type, $show_in_menu ), // $parent slug … … 38 35 } 39 36 37 40 38 /** 41 39 * Register Setting, Settings Section, and Settings Field 42 40 */ 43 44 add_action( 'admin_init', 'ptad_register_settings' );45 41 function ptad_register_settings() { 46 42 … … 57 53 foreach ( $post_types as $post_type ) : 58 54 59 if ( post_type_exists( $post_type ) ) :55 if( post_type_exists( $post_type ) ) : 60 56 61 57 // Register settings and call sanitization functions … … 75 71 'ptad_settings_section_' . $post_type, // $section 76 72 array( // $args 77 'post_type' => $post_type,73 'post_type' => $post_type, 78 74 'field_name' => 'ptad_descriptions[' . $post_type . ']', 79 'label_for' => 'ptad_descriptions[' . $post_type . ']'75 'label_for' 80 76 ) 81 77 ); … … 91 87 92 88 $post_type = str_replace( 'ptad_settings_section_', '', $args['id'] ); 93 89 94 90 /** 95 91 * Action before Description editor field in the admin 96 92 * 97 * $post_type 93 * $post_type slug of post type the description is for 98 94 */ 99 95 do_action( 'ptad_before_editor', $post_type ); 100 96 101 97 /** 102 98 * Action before Description editor field in the admin only for a specific post type … … 117 113 $descriptions = (array) get_option( 'ptad_descriptions' ); 118 114 119 if ( array_key_exists($post_type, $descriptions) ) {120 $description = $descriptions[ $post_type];115 if) ) { 116 $description = $descriptions[]; 121 117 } else { 122 118 $description = ''; … … 127 123 'textarea_rows' => 15, 128 124 'media_buttons' => true, 129 'classes' => 'wp-editor-area wp-editor'125 'classes' 130 126 ); 131 127 … … 137 133 * Action before Description editor field in the admin 138 134 * 139 * $post_type 135 * $post_type slug of post type the description is for 140 136 */ 141 137 do_action( 'ptad_after_editor', $post_type ); 142 138 143 139 /** 144 140 * Action before Description editor field in the admin only for a specific post type … … 147 143 */ 148 144 do_action( 'ptad_after_editor_' . $post_type ); 149 145 150 146 if ( ! defined( 'QTX_VERSION' ) ) { 151 147 add_filter( 'the_editor', 'qtranslate_admin_loadConfig' ); 152 148 } 153 149 154 150 } 155 151 … … 160 156 161 157 // occurs when parent menu item is not the post type 162 if ( empty( $post_type ) ) {158 if( empty( $post_type ) ) { 163 159 $post_type = ptad_get_post_type_from_admin_page_slug(); 164 160 } 165 161 ?> 166 167 162 <div class="wrap"> 168 <h2><?php echo ptad_settings_page_title( $post_type, 'name'); ?></h2>163 <h2><?php echo ); ?></h2> 169 164 <form action="options.php" method="POST"> 170 165 <?php settings_fields( 'ptad_descriptions' ); ?> … … 186 181 187 182 // 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 ); 190 185 } 191 186 … … 199 194 /** 200 195 * Return capability that's allowed to edit posts 201 * 196 * 202 197 * See: http://core.trac.wordpress.org/ticket/14365 203 198 */ … … 208 203 /** 209 204 * filter the capability for who can edit descriptions 210 * 205 * 211 206 * @param string $capability capability required to edit post type descriptions (default: edit_posts) 212 207 */ 213 208 $capability = apply_filters( 'ptad_description_capability', $capability ); 214 209 215 210 return esc_attr( $capability ); 216 211 … … 226 221 */ 227 222 function ptad_settings_page_parent( $post_type, $show_in_menu = false ) { 228 223 229 224 $settings_page_parent = $show_in_menu; 230 225 231 226 // 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 ) ) { 233 228 $settings_page_parent = "edit.php?post_type=$post_type"; 234 229 } 235 230 236 231 /** 237 232 * filter for parent of Archive Settings page … … 248 243 /** 249 244 * Output filterable name of Settings page 250 * 245 * 251 246 * @param string $post_type name of post type for the page 252 * @param 'label'|'name' $p t_valwhether $post_type is the label (default) or name247 * @param 'label'|'name' $p whether $post_type is the label (default) or name 253 248 * @return name for settings page 254 249 */ 255 function ptad_settings_page_title( $post_type, $p t_val= 'label' ) {256 257 if ( $pt_val== 'name' ) {250 function ptad_settings_page_title( $post_type, $p = 'label' ) { 251 252 if== 'name' ) { 258 253 $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 ); 262 258 263 259 /** 264 260 * filter for admin menu label 265 * 261 * 266 262 * @param string $settings_page_menu_label label text (default: "Description for the {Post Type} Archive") 267 263 * @param string $post_type post_type name if needed … … 276 272 * Output filterable menu label for a post type's description settings page. 277 273 * @param string $post_type post_type to create label for 278 * @param 'label'|'name' $p t_valwhether $post_type is the label (default) or name274 * @param 'label'|'name' $p whether $post_type is the label (default) or name 279 275 * @return string admin menu label 280 276 */ 281 function ptad_settings_menu_label( $post_type, $p t_val= 'label' ) {282 283 if ( $pt_val== 'name' ) {277 function ptad_settings_menu_label( $post_type, $p = 'label' ) { 278 279 if== 'name' ) { 284 280 $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; 286 282 } 287 283 … … 290 286 /** 291 287 * filter for admin menu label 292 * 288 * 293 289 * @param string $settings_page_menu_label label text (default: "Description") 294 290 * @param string $post_type post_type name if needed -
post-type-archive-descriptions/trunk/inc/template-tags.php
r2470184 r2981804 1 1 <?php 2 /****************************************************3 *4 * Functions to get Description Page Content5 *6 ****************************************************/7 2 /** 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 * 12 12 * @param string $post_type slug for post type to show description for (optional) 13 13 * @return string post type description … … 18 18 19 19 /** 20 * return post type archive description21 * 22 * if on a post type archive, automatically grabs current post type23 * 20 * eturn post type archive description 21 * 22 * f on a post type archive, automatically grabs current post type 23 * 24 24 * @param string $post_type slug for post type to show description for (optional) 25 25 * @return string post type description 26 26 */ 27 27 function ptad_get_post_type_description( $post_type = '' ) { 28 28 29 29 // get global $post_type if not specified 30 if ( '' == $post_type ) {30 if ( '' == $post_type ) { 31 31 $post_type = ptad_get_post_type_from_queried_object(); 32 32 } … … 34 34 $all_descriptions = (array) get_option( 'ptad_descriptions' ); 35 35 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[]; 38 38 } else { 39 39 $post_type_description = ''; 40 40 } 41 41 42 43 42 44 $description = apply_filters( 'the_content', $post_type_description ); 43 45 -
post-type-archive-descriptions/trunk/post-type-archive-descriptions.php
r2745967 r2981804 5 5 Author: Mark Root-Wiley, MRW Web Design, NonprofitWP.org 6 6 Author URI: https://MRWweb.com 7 Version: 1. 4.07 Version: 1..0 8 8 License: GPL v3 9 9 Text Domain: post-type-archive-descriptions … … 26 26 */ 27 27 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' );28 require_once; 29 require_once; 30 require_once; 31 require_once; 32 32 33 require_once ( 'compat/wordpress-core.php' );34 require_once ( 'compat/qtranslate-x.php' );35 require_once ( 'compat/the-events-calendar.php' );33 require_once; 34 require_once; 35 require_once; -
post-type-archive-descriptions/trunk/readme.txt
r2745967 r2981804 6 6 Tags: custom post type, custom post types, post type archive, archives, custom post type archive 7 7 Requires at least: 4.6 8 Tested up to: 6. 09 Stable tag: 1. 4.08 Tested up to: 6. 9 Stable tag: 1..0 10 10 11 11 == Description == … … 110 110 111 111 == Changelog == 112 113 114 115 116 112 117 = 1.4.0 (June 21, 2022) = 113 118 * Tested up to 6.0. … … 120 125 == Upgrade Notice == 121 126 = 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.127 Tested up to WP 6..
Note: See TracChangeset
for help on using the changeset viewer.