Changeset 2713271
- Timestamp:
- 04/22/2022 10:50:36 AM (2 years ago)
- Location:
- wp-subtitle/tags/3.4.1
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-subtitle/tags/3.4.1/plugin/admin/admin.php
r2712645 r2713271 48 48 $position = self::subtitle_field_position( $post_type ); 49 49 50 if ( 'after_title' == $position ) {50 if ( 'after_title' == $position ) { 51 51 add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) ); 52 52 add_action( 'edit_form_after_title', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) ); 53 } elseif ( 'before_title' == $position ) {53 } elseif ( 'before_title' == $position ) { 54 54 add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) ); 55 55 add_action( 'edit_form_top', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) ); … … 76 76 77 77 if ( isset( $_REQUEST['post_type'] ) ) { 78 return sanitize_text_field( $_REQUEST['post_type']);78 return sanitize_text_field( ); 79 79 } elseif ( isset( $_GET['post'] ) ) { 80 80 return get_post_type( absint( $_GET['post'] ) ); 81 } elseif ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ) ) ) {81 } elseif ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ) ) ) { 82 82 return 'post'; 83 83 } … … 94 94 * @uses add_action( 'quick_edit_custom_box' ) 95 95 * 96 * @param string 97 * @param string $post_typePost type96 * @param string $column_name Column name. 97 * @param string Post type 98 98 */ 99 99 public static function quick_edit_custom_box( $column_name, $post_type ) { 100 100 101 if ( $column_name !== 'wps_subtitle') {101 if ( ) { 102 102 return; 103 103 } … … 107 107 ?> 108 108 <fieldset class="inline-edit-col-left inline-edit-col-left-wps-subtitle"> 109 <div class="inline-edit-col column- <?php echo $column_name; ?>">109 <div class="inline-edit-col column-"> 110 110 <label> 111 111 <span class="title"><?php esc_html_e( 'Subtitle', 'wp-subtitle' ); ?></span> … … 123 123 * @since 2.4 124 124 * 125 * @param array 125 * @param array $columns A columns 126 126 * @return array Updated columns. 127 127 */ … … 149 149 foreach ( $columns as $column => $value ) { 150 150 $new_columns[ $column ] = $value; 151 if ( $after_column == $column ) {151 if ( $after_column == $column ) { 152 152 $new_columns['wps_subtitle'] = $column_name; 153 153 } … … 163 163 * @since 2.4 164 164 * 165 * @param string 166 * @param int 165 * @param string $column_name Column name. 166 * @param int $post_id Post ID 167 167 */ 168 168 public static function manage_subtitle_columns_content( $column_name, $post_id ) { 169 169 170 if ( $column_name == 'wps_subtitle') {170 if ( ) { 171 171 172 172 $subtitle = new WP_Subtitle( $post_id ); … … 185 185 public static function _add_admin_scripts( $hook ) { 186 186 187 if ( 'edit.php' != $hook ) {187 if ( 'edit.php' != $hook ) { 188 188 return; 189 189 } 190 190 191 wp_enqueue_script( 'wps_subtitle', plugins_url( 'js/admin-edit.js', __FILE__ ), false, null, true );191 wp_enqueue_script( 'wps_subtitle', plugins_url( 'js/admin-edit.js', __FILE__ ), false, , true ); 192 192 193 193 } … … 199 199 * @internal 200 200 * 201 * @param array 201 * @param array $fields Revision fields. 202 202 */ 203 203 public static function _wp_post_revision_fields( $fields ) { … … 214 214 * @since 2.9 215 215 * 216 * @param int 217 * @param int 216 * @param int $post_id Post ID. 217 * @param int $revision_id Revision ID. 218 218 */ 219 219 public static function wp_restore_post_revision( $post_id, $revision_id ) { … … 293 293 $positiom = self::gutenberg_supported( $post_type ) ? 'side' : 'normal'; 294 294 295 add_meta_box( 'wps_subtitle_panel', 295 add_meta_box( 'wps_subtitle_panel', self::get_meta_box_title( $post_type ), array( 'WPSubtitle_Admin', '_add_subtitle_meta_box' ), $post_type, $positiom, 'high' ); 296 296 297 297 } … … 313 313 $value = self::get_admin_subtitle_value( $post ); 314 314 315 echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle') . '" />';315 echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . ) . '" />'; 316 316 317 317 // As of WordPress 4.3 no need to esc_attr() AND htmlentities(). … … 319 319 echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . esc_attr( $value ) . '" autocomplete="off" placeholder="' . esc_attr( apply_filters( 'wps_subtitle_field_placeholder', __( 'Enter subtitle here', 'wp-subtitle' ), $post ) ) . '" style="width:99%;" />'; 320 320 321 echo apply_filters( 'wps_subtitle_field_description', '', $post);321 echo ); 322 322 323 323 } … … 338 338 $value = self::get_admin_subtitle_value( $post ); 339 339 340 echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle') . '" />';340 echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . ) . '" />'; 341 341 echo '<div id="subtitlediv" class="top">'; 342 342 echo '<div id="subtitlewrap">'; … … 351 351 $description = apply_filters( 'wps_subtitle_field_description', '', $post ); 352 352 if ( ! empty( $description ) ) { 353 echo '<div id="subtitledescription">' . $description. '</div>';353 echo '<div id="subtitledescription">' . . '</div>'; 354 354 } 355 355 echo '</div>'; … … 362 362 * @internal 363 363 * 364 * @param WP_Post 364 * @param WP_Post $post Post object. 365 365 * @return string Subtitle value. 366 366 */ … … 374 374 if ( function_exists( 'get_current_screen' ) && empty( $value ) ) { 375 375 $screen = get_current_screen(); 376 if ( isset( $screen->action ) && 'add' == $screen->action ) {376 if ( isset( $screen->action ) && 'add' == $screen->action ) { 377 377 $value = $subtitle->get_default_subtitle( $post ); 378 378 } … … 391 391 * @uses WPSubtitle::get_supported_post_types() 392 392 * 393 * @param int 393 * @param int $post_id Post ID or object. 394 394 */ 395 395 public static function _save_post( $post_id ) { 396 396 397 // Verify if this is an auto save routine. 397 // Verify if this is an auto save routine. 398 398 // If it is our form has not been submitted, so we dont want to do anything 399 399 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { … … 409 409 if ( isset( $_POST['wps_subtitle'] ) ) { 410 410 411 $new_value = wp_kses_post( $_POST['wps_subtitle']);411 $new_value = wp_kses_post( ); 412 412 413 413 $subtitle = new WP_Subtitle( $post_id ); … … 421 421 $subtitle->update_subtitle( $new_value ); 422 422 } 423 424 423 } 425 424 … … 433 432 * @internal 434 433 * 435 * @param int 434 * @param int $post_id Post ID. 436 435 * @return bool 437 436 */ … … 452 451 * @internal 453 452 * 454 * @param string 455 * @param string 453 * @param string $nonce Posted nonce name. 454 * @param string $action Nonce action. 456 455 * @return bool 457 456 */ 458 457 private static function _verify_posted_nonce( $nonce, $action ) { 459 if ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( $_POST[ $nonce ], $action ) ) {458 if ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( , $action ) ) { 460 459 return true; 461 460 } … … 468 467 * @since 2.2 469 468 * 470 * @param string 469 * @param string $post_type Post type. 471 470 * @return bool 472 471 */ … … 485 484 * @since 3.1 486 485 * 487 * @param string 486 * @param string $post_type Post type. 488 487 * @return bool 489 488 */ … … 503 502 * @since 3.1 504 503 * 505 * @param string$post_type Post type.506 * @ paramstring Position.504 * @param $post_type Post type. 505 * @ string Position. 507 506 */ 508 507 private static function subtitle_field_position( $post_type = '' ) { -
wp-subtitle/tags/3.4.1/plugin/admin/js/admin-edit.js
r2151217 r2713271 9 9 // propagation to all other event handlers; swap it out. 10 10 inlineEditPost.editPreWpSubtitle = inlineEditPost.edit; 11 inlineEditPost.edit = function ( id ) {11 inlineEditPost.edit = function ( id ) { 12 12 13 13 // Invoke original edit event handler. … … 36 36 } 37 37 38 } ) 38 } )( jQuery, inlineEditPost ); -
wp-subtitle/tags/3.4.1/plugin/admin/js/pointers.js
r2151217 r2713271 1 2 1 /** 3 2 * @package WP Subtitle … … 5 4 */ 6 5 7 jQuery( document ).ready( function( $ ) { 6 jQuery( document ).ready( 7 function( $ ) { 8 8 9 function wps_subtitle_open_pointer( i ) { 10 pointer = wpsSubtitlePointer.pointers[ i ]; 11 options = $.extend( pointer.options, { 12 close : function() { 13 $.post( ajaxurl, { 14 pointer : pointer.pointer_id, 15 action : 'dismiss-wp-pointer' 16 } ); 17 } 18 }); 9 function wps_subtitle_open_pointer( i ) { 10 pointer = wpsSubtitlePointer.pointers[ i ]; 11 options = $.extend( 12 pointer.options, 13 { 14 close : function() { 15 $.post( 16 ajaxurl, 17 { 18 pointer : pointer.pointer_id, 19 action : 'dismiss-wp-pointer' 20 } 21 ); 22 } 23 } 24 ); 19 25 20 $( pointer.target ).pointer( options ).pointer( 'open' ); 26 $( pointer.target ).pointer( options ).pointer( 'open' ); 27 } 28 29 wps_subtitle_open_pointer( 0 ); 30 21 31 } 22 23 wps_subtitle_open_pointer( 0 ); 24 25 } ); 32 ); -
wp-subtitle/tags/3.4.1/plugin/admin/pointers.php
r2151217 r2713271 32 32 * @internal 33 33 * 34 * @param string 34 * @param string $hook_suffix Page hook. 35 35 */ 36 36 public static function _pointer_load( $hook_suffix ) { … … 55 55 // Enqueue pointer scripts and styles. 56 56 wp_enqueue_style( 'wp-pointer' ); 57 wp_enqueue_script( 'wps-subtitle-pointer', plugins_url( 'js/pointers.js', __FILE__ ), array( 'wp-pointer' ) );57 wp_enqueue_script( 'wps-subtitle-pointer', plugins_url( 'js/pointers.js', __FILE__ ), array( 'wp-pointer' ) ); 58 58 wp_localize_script( 'wps-subtitle-pointer', 'wpsSubtitlePointer', $valid_pointers ); 59 59 … … 72 72 private static function get_current_pointers() { 73 73 74 $screen = get_current_screen();74 $screen = get_current_screen(); 75 75 $pointers = apply_filters( 'wps_subtitle_admin_pointers-' . $screen->id, array() ); 76 76 … … 90 90 * @internal 91 91 * 92 * @param array 92 * @param array $pointers Pointers. 93 93 * @return array Active pointers. 94 94 */ 95 95 private static function remove_dismissed_pointers( $pointers ) { 96 96 97 $dismissed = self::get_dismissed_pointers();97 $dismissed = self::get_dismissed_pointers(); 98 98 $valid_pointers = array(); 99 99 … … 102 102 103 103 // Sanity check 104 if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) 104 if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) { 105 105 continue; 106 106 } … … 137 137 * @internal 138 138 * 139 * @param array 139 * @param array $pointers Pointers. 140 140 * @return array Pointers. 141 141 */ … … 146 146 'target' => '#subtitlewrap', 147 147 'options' => array( 148 'content' => sprintf( '<h3>%s</h3><p>%s</p>', 148 'content' => sprintf( 149 '<h3>%s</h3><p>%s</p>', 149 150 sprintf( __( '%s Field', 'wp-subtitle' ), WPSubtitle_Admin::get_meta_box_title( get_post_type( get_queried_object_id() ) ) ), 150 151 __( 'This field has moved from a meta box to below the post title.', 'wp-subtitle' ) … … 152 153 'position' => array( 153 154 'edge' => 'top', 154 'align' => 'middle' 155 ) 156 ) 155 'align' => 'middle' 156 ) 157 ) 157 158 ); 158 159 -
wp-subtitle/tags/3.4.1/plugin/includes/class-api.php
r2151217 r2713271 23 23 */ 24 24 25 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 25 if ( ! defined( 'ABSPATH' ) ) { 26 exit; // Exit if accessed directly 27 } 26 28 27 29 class WP_Subtitle_API { … … 40 42 * The Subtitle 41 43 * 42 * @param array 44 * @param array $args Display args. 43 45 * 44 46 * @internal Private. Called via the `the_subtitle` action. … … 48 50 $default_value = isset( $args['default_value'] ) ? $args['default_value'] : ''; 49 51 50 echo $this->get_subtitle( $default_value, $args);52 echo ); 51 53 52 54 } … … 55 57 * Get Subtitle 56 58 * 57 * @param string 58 * @param array 59 * @param string $default_subtitle Default/fallback subtitle. 60 * @param array $args Display args. 59 61 * @return string The subtitle. 60 62 * … … 63 65 public function get_subtitle( $default_subtitle, $args = '' ) { 64 66 65 $args = wp_parse_args( $args, array( 66 'post_id' => get_the_ID(), // Post ID 67 'before' => '', // Before subtitle HTML output 68 'after' => '' // After subtitle HTML output 69 ) ); 67 $args = wp_parse_args( 68 $args, 69 array( 70 'post_id' => get_the_ID(), // Post ID 71 'before' => '', // Before subtitle HTML output 72 'after' => '', // After subtitle HTML output 73 ) 74 ); 70 75 71 76 $subtitle_obj = new WP_Subtitle( $args['post_id'] ); 72 $subtitle = $subtitle_obj->get_subtitle( $args );77 $subtitle = $subtitle_obj->get_subtitle( $args ); 73 78 74 79 if ( ! empty( $subtitle ) ) { -
wp-subtitle/tags/3.4.1/plugin/includes/compat/seopress.php
r2240907 r2713271 51 51 * @since 3.4 52 52 * 53 * @param array 53 * @param array $replacements SEO replacements variables. 54 54 * @return array Filtered replacements variables. 55 55 * … … 71 71 * @since 3.4 72 72 * 73 * @param array 73 * @param array $replacements SEO replacements values. 74 74 * @return array Filtered replacements values. 75 75 * … … 81 81 82 82 $wp_subtitle = new WP_Subtitle( $post ); 83 $subtitle = $wp_subtitle->get_subtitle();83 $subtitle = $wp_subtitle->get_subtitle(); 84 84 85 85 $replacements[] = $subtitle; … … 88 88 89 89 $before_sep = ''; 90 $after_sep = '';90 $after_sep = ''; 91 91 92 92 if ( ! empty( $subtitle ) ) { 93 93 94 94 $before_sep = apply_filters( 'wps_subtitle_seo_before_sep', $sep ); 95 $after_sep = apply_filters( 'wps_subtitle_seo_after_sep', $sep );95 $after_sep = apply_filters( 'wps_subtitle_seo_after_sep', $sep ); 96 96 97 97 } -
wp-subtitle/tags/3.4.1/plugin/includes/compat/woocommerce.php
r2235496 r2713271 22 22 public function __construct() { 23 23 24 if ( 'yes' == get_option( 'wp_subtitle_woocommerce_enabled' ) ) {24 if ( 'yes' == get_option( 'wp_subtitle_woocommerce_enabled' ) ) { 25 25 26 26 add_action( 'init', array( $this, 'add_product_post_type_support' ) ); 27 27 28 if ( 'yes' == get_option( 'wp_subtitle_woocommerce_show_on_single' ) ) {29 add_action( 'woocommerce_single_product_summary' 28 if ( 'yes' == get_option( 'wp_subtitle_woocommerce_show_on_single' ) ) { 29 add_action( 'woocommerce_single_product_summary', array( $this, 'single_product_summary' ), 6 ); 30 30 } 31 31 32 if ( 'yes' == get_option( 'wp_subtitle_woocommerce_show_in_loop' ) ) {33 add_action( 'woocommerce_shop_loop_item_title' 32 if ( 'yes' == get_option( 'wp_subtitle_woocommerce_show_in_loop' ) ) { 33 add_action( 'woocommerce_shop_loop_item_title', array( $this, 'shop_loop_item_title' ) ); 34 34 } 35 36 35 } 37 36 38 add_filter( 'woocommerce_product_settings' 37 add_filter( 'woocommerce_product_settings', array( $this, 'product_settings' ) ); 39 38 40 39 } … … 62 61 public function single_product_summary() { 63 62 64 do_action( 'plugins/wp_subtitle/the_subtitle', array( 65 'before' => '<h2 class="product_subtitle entry-subtitle wp-subtitle">', 66 'after' => '</h2>' 67 ) ); 63 do_action( 64 'plugins/wp_subtitle/the_subtitle', 65 array( 66 'before' => '<h2 class="product_subtitle entry-subtitle wp-subtitle">', 67 'after' => '</h2>', 68 ) 69 ); 68 70 69 71 } … … 78 80 public function shop_loop_item_title() { 79 81 80 do_action( 'plugins/wp_subtitle/the_subtitle', array( 81 'before' => '<p class="woocommerce-loop-product__subtitle wp-subtitle">', 82 'after' => '</p>' 83 ) ); 82 do_action( 83 'plugins/wp_subtitle/the_subtitle', 84 array( 85 'before' => '<p class="woocommerce-loop-product__subtitle wp-subtitle">', 86 'after' => '</p>', 87 ) 88 ); 84 89 85 90 } … … 90 95 * @since 3.1 91 96 * 92 * @param array 97 * @param array $settings Settings. 93 98 * @return array Settings. 94 99 * … … 103 108 'type' => 'title', 104 109 'desc' => '', 105 'id' => 'wp_subtitle_options' 110 'id' => 'wp_subtitle_options' 106 111 ), 107 112 … … 120 125 'default' => 'yes', 121 126 'type' => 'checkbox', 122 'checkboxgroup' => 'start' 127 'checkboxgroup' => 'start' 123 128 ), 124 129 … … 128 133 'default' => 'yes', 129 134 'type' => 'checkbox', 130 'checkboxgroup' => 'end' 135 'checkboxgroup' => 'end' 131 136 ), 132 137 133 138 array( 134 139 'type' => 'sectionend', 135 'id' => 'wp_subtitle_options' 136 ) 140 'id' => 'wp_subtitle_options' 141 ) 137 142 138 143 ); -
wp-subtitle/tags/3.4.1/plugin/includes/compat/wordpress-seo.php
r2151217 r2713271 50 50 * @since 3.1 51 51 * 52 * @param array 52 * @param array $replacements SEO replacements. 53 53 * @return array Filtered replacements. 54 54 * … … 60 60 61 61 $wp_subtitle = new WP_Subtitle( $post ); 62 $subtitle = $wp_subtitle->get_subtitle();62 $subtitle = $wp_subtitle->get_subtitle(); 63 63 64 $replacements['%%wps_subtitle%%'] = $subtitle;64 $replacements['%%wps_subtitle%%'] = $subtitle; 65 65 $replacements['%%wps_subtitle_before_sep%%'] = ''; 66 $replacements['%%wps_subtitle_after_sep%%'] = '';66 $replacements['%%wps_subtitle_after_sep%%'] = ''; 67 67 68 68 if ( ! empty( $subtitle ) ) { … … 71 71 72 72 $replacements['%%wps_subtitle_before_sep%%'] = apply_filters( 'wps_subtitle_seo_before_sep', $sep ); 73 $replacements['%%wps_subtitle_after_sep%%'] = apply_filters( 'wps_subtitle_seo_after_sep', $sep );73 $replacements['%%wps_subtitle_after_sep%%'] = apply_filters( 'wps_subtitle_seo_after_sep', $sep ); 74 74 75 75 } -
wp-subtitle/tags/3.4.1/plugin/includes/deprecated.php
r2151217 r2713271 14 14 * @uses WP_Subtitle::get_subtitle() 15 15 * 16 * @param string 17 * @param string 18 * @param bool 16 * @param string $before Before the subtitle. 17 * @param string $after After the subtitle. 18 * @param bool $echo Output if true, return if false. 19 19 * @return string The subtitle string. 20 20 */ … … 23 23 if ( ! $echo ) { 24 24 25 return apply_filters( 'plugins/wp_subtitle/get_subtitle', '', array( 26 'before' => $before, 27 'after' => $after 28 ) ); 25 return apply_filters( 26 'plugins/wp_subtitle/get_subtitle', 27 '', 28 array( 29 'before' => $before, 30 'after' => $after, 31 ) 32 ); 29 33 30 34 } 31 35 32 do_action( 'plugins/wp_subtitle/the_subtitle', array( 33 'before' => $before, 34 'after' => $after 35 ) ); 36 do_action( 37 'plugins/wp_subtitle/the_subtitle', 38 array( 39 'before' => $before, 40 'after' => $after, 41 ) 42 ); 36 43 37 44 } … … 45 52 * @uses WP_Subtitle::get_subtitle() 46 53 * 47 * @param int|object 48 * @param string 49 * @param string 50 * @param bool 54 * @param int|object $post Post ID or object. 55 * @param string $before Before the subtitle. 56 * @param string $after After the subtitle. 57 * @param bool $echo Output if true, return if false. 51 58 * @return string The subtitle string. 52 59 */ 53 60 function get_the_subtitle( $post = 0, $before = '', $after = '', $echo = true ) { 54 61 55 $output = apply_filters( 'plugins/wp_subtitle/get_subtitle', '', array( 56 'post_id' => is_a( $post, 'WP_Post' ) ? $post->ID : $post, 57 'before' => $before, 58 'after' => $after 59 ) ); 62 $output = apply_filters( 63 'plugins/wp_subtitle/get_subtitle', 64 '', 65 array( 66 'post_id' => is_a( $post, 'WP_Post' ) ? $post->ID : $post, 67 'before' => $before, 68 'after' => $after, 69 ) 70 ); 60 71 61 72 if ( ! $echo ) { … … 63 74 } 64 75 65 echo $output;76 echo ; 66 77 67 78 } … … 128 139 * @since 1.0 129 140 * @deprecated 2.0 Legacy function. 141 142 130 143 */ 131 144 function wps_saveSubtitle( $post_id ) { -
wp-subtitle/tags/3.4.1/plugin/includes/rest.php
r2240907 r2713271 36 36 foreach ( $post_types as $post_type ) { 37 37 38 register_rest_field( $post_types, 'wps_subtitle', array( 39 'get_callback' => array( $this, 'get_rest_field' ), 40 'update_callback' => array( $this, 'update_rest_field' ), 41 'schema' => null 42 ) ); 38 register_rest_field( 39 $post_types, 40 'wps_subtitle', 41 array( 42 'get_callback' => array( $this, 'get_rest_field' ), 43 'update_callback' => array( $this, 'update_rest_field' ), 44 'schema' => null, 45 ) 46 ); 43 47 44 48 } … … 53 57 * @internal Called via register_rest_field() callback. 54 58 * 55 * @param array 56 * @param string 57 * @param WP_REST_Request 59 * @param array $object Current post details. 60 * @param string $field_name Name of field. 61 * @param WP_REST_Request $request Current request. 58 62 * @return string Subtitle 59 63 */ … … 73 77 * @internal Called via register_rest_field() callback. 74 78 * 75 * @param string 76 * @param array 79 * @param string $value New value for the field. 80 * @param array $object Current post details. 77 81 */ 78 82 public function update_rest_field( $value, $object ) { -
wp-subtitle/tags/3.4.1/plugin/includes/shortcode.php
r2151217 r2713271 16 16 * e.g. [wp_subtitle]Fallback Subtitle[/wp_subtitle] 17 17 * 18 * @param array 19 * @param string 18 * @param array $atts Shortcode attributes. 19 * @param string $content Fallback content (content between the shortcode tags). 20 20 * @return string Subtitle HTML. 21 21 */ … … 24 24 global $post; 25 25 26 $atts = shortcode_atts( array( 27 'tag' => self::get_default_tag(), 28 'before' => '', 29 'after' => '' 30 ), $atts, 'wp_subtitle' ); 26 $atts = shortcode_atts( 27 array( 28 'tag' => self::get_default_tag(), 29 'before' => '', 30 'after' => '', 31 ), 32 $atts, 33 'wp_subtitle' 34 ); 31 35 32 36 // Get HTML tag 33 37 if ( ! empty( $atts['tag'] ) ) { 34 $tag = self::validate_tag( $atts['tag'] );38 $tag = self::validate_tag( $atts['tag'] ); 35 39 $before = sprintf( '<%s class="wp-subtitle">', $tag ); 36 $after = sprintf( '</%s>', $tag );40 $after = sprintf( '</%s>', $tag ); 37 41 } else { 38 42 $before = ''; 39 $after = '';43 $after = ''; 40 44 } 41 45 42 46 // Add before/after content 43 47 $before .= self::format_subtitle_content( $atts['before'], 'before' ); 44 $after = self::format_subtitle_content( $atts['after'], 'after' ) . $after;48 $after = self::format_subtitle_content( $atts['after'], 'after' ) . $after; 45 49 46 50 $subtitle = new WP_Subtitle( $post ); 47 51 48 return $subtitle->get_subtitle( array( 49 'before' => $before, 50 'after' => $after 51 ) ); 52 return $subtitle->get_subtitle( 53 array( 54 'before' => $before, 55 'after' => $after, 56 ) 57 ); 52 58 53 59 } … … 89 95 * @internal 90 96 * 91 * @param string 97 * @param string $tag Tag to validate. 92 98 * @return string Validated tag. 93 99 */ 94 100 private static function validate_tag( $tag ) { 95 101 96 if ( ! in_array( $tag, self::get_allowed_tags() ) ) {102 if ( ! in_array( $tag, self::get_allowed_tags() ) ) { 97 103 $tag = self::get_default_tag(); 98 104 } … … 108 114 * @internal 109 115 * 110 * @param string 111 * @param string 116 * @param string $content Content. 117 * @param string $type Content type. 112 118 * @return string HTML formatted content. 113 119 */ -
wp-subtitle/tags/3.4.1/plugin/includes/subtitle.php
r2151217 r2713271 18 18 * Constructor 19 19 * 20 * @param int|WP_Post 20 * @param int|WP_Post $post Post object or ID. 21 21 */ 22 22 public function __construct( $post ) { … … 34 34 * The Subtitle 35 35 * 36 * @param array 36 * @param array $args Display parameters. 37 37 */ 38 38 public function the_subtitle( $args = '' ) { 39 39 40 echo $this->get_subtitle( $args);40 echo ); 41 41 42 42 } … … 47 47 * @uses apply_filters( 'wps_subtitle' ) 48 48 * 49 * @param array 49 * @param array $args Display parameters. 50 50 * @return string The filtered subtitle meta value. 51 51 */ … … 54 54 if ( $this->post_id && $this->is_supported_post_type() ) { 55 55 56 $args = wp_parse_args( $args, array( 57 'before' => '', 58 'after' => '' 59 ) ); 56 $args = wp_parse_args( 57 $args, 58 array( 59 'before' => '', 60 'after' => '', 61 ) 62 ); 60 63 61 64 $subtitle = apply_filters( 'wps_subtitle', $this->get_raw_subtitle(), get_post( $this->post_id ) ); … … 83 86 84 87 if ( isset( $_GET['preview_id'] ) ) { 85 $p = 88 $p = wp_get_post_autosave( $this->post_id ); 86 89 return get_post_meta( $p->ID, $this->get_post_meta_key(), true ); 87 90 } 88 91 89 if ( $revisions = wp_get_post_revisions( $this->post_id ) ) { 92 $revisions = wp_get_post_revisions( $this->post_id ); 93 94 if ( $revisions ) { 90 95 $p = array_shift( $revisions ); 91 96 return get_post_meta( $p->ID, $this->get_post_meta_key(), true ); 92 97 } 93 94 98 } 95 99 … … 114 118 * Update Subtitle 115 119 * 116 * @param string 120 * @param string $subtitle Subtitle. 117 121 * @return int|bool Meta ID if new entry. True if updated, false if not updated or the same as current value. 118 122 */ … … 129 133 * @since 2.9 130 134 * 131 * @param string 135 * @param string $subtitle Subtitle value. 132 136 * @return boolean 133 137 */ 134 138 public function is_current_subtitle( $subtitle ) { 135 139 136 return $subtitle === get_metadata( 'post', $this->post_id, 'wps_subtitle', true );140 return ; 137 141 138 142 } … … 156 160 * @since 2.9 157 161 * 158 * @param int 162 * @param int $revision_id Revision ID. 159 163 */ 160 164 public function restore_post_revision( $revision_id ) { … … 179 183 $post_types = $this->get_supported_post_types(); 180 184 181 return in_array( get_post_type( $this->post_id ), $post_types );185 return in_array( get_post_type( $this->post_id ), $post_types ); 182 186 183 187 } … … 192 196 private function get_supported_post_types() { 193 197 194 $post_types = (array) get_post_types( array( 195 '_builtin' => false 196 ) ); 198 $post_types = (array) get_post_types( 199 array( 200 '_builtin' => false, 201 ) 202 ); 197 203 198 204 $post_types = array_merge( $post_types, array( 'post', 'page', 'revision' ) ); … … 223 229 224 230 $post_type = get_post_type( $this->post_id ); 225 226 if ( $revision = wp_is_post_revision( $this->post_id ) ) { 231 $revision = wp_is_post_revision( $this->post_id ); 232 233 if ( $revision ) { 227 234 $post_type = get_post_type( $revision ); 228 235 } … … 241 248 // ... edit other post type 242 249 default: 243 244 $post_types = (array) get_post_types( array( 245 '_builtin' => false 246 ), 'objects' ); 250 $post_types = (array) get_post_types( 251 array( 252 '_builtin' => false, 253 ), 254 'objects' 255 ); 247 256 248 257 return current_user_can( $post_types[ $post_type ]->cap->edit_post, $this->post_id ); 249 258 250 259 } 251 252 260 } 253 261 -
wp-subtitle/tags/3.4.1/plugin/plugin.php
r2240907 r2713271 13 13 14 14 // Includes 15 include_once( WPSUBTITLE_DIR . 'includes/class-api.php' );16 include_once( WPSUBTITLE_DIR . 'includes/subtitle.php' );17 include_once( WPSUBTITLE_DIR . 'includes/deprecated.php' );18 include_once( WPSUBTITLE_DIR . 'includes/shortcode.php' );19 include_once( WPSUBTITLE_DIR . 'includes/rest.php' );20 include_once( WPSUBTITLE_DIR . 'includes/compat/wordpress-seo.php' );21 include_once( WPSUBTITLE_DIR . 'includes/compat/seopress.php' );22 include_once( WPSUBTITLE_DIR . 'includes/compat/woocommerce.php' );15 ; 16 ; 17 ; 18 ; 19 ; 20 ; 21 ; 22 ; 23 23 24 24 // Include admin-only functionality 25 25 if ( is_admin() ) { 26 require_once ( WPSUBTITLE_DIR . 'admin/admin.php' );26 require_once; 27 27 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 28 28 // Load AJAX functions here if required... 29 29 } else { 30 require_once ( WPSUBTITLE_DIR . 'admin/pointers.php' );30 require_once; 31 31 } 32 32 } … … 91 91 public static function load() { 92 92 93 self::$api = new WP_Subtitle_API();94 self::$rest = new WPSubtitle_REST();95 self::$wpseo = new WPSubtitle_WPSEO();96 self::$seopress = new WPSubtitle_SEOPress();93 self::$api = new WP_Subtitle_API(); 94 self::$rest = new WPSubtitle_REST(); 95 self::$wpseo = new WPSubtitle_WPSEO(); 96 self::$seopress = new WPSubtitle_SEOPress(); 97 97 self::$woocommerce = new WPSubtitle_WooCommerce(); 98 98 … … 123 123 */ 124 124 public static function get_supported_post_types() { 125 $post_types = (array) get_post_types( array( 126 '_builtin' => false 127 ) ); 125 $post_types = (array) get_post_types( 126 array( 127 '_builtin' => false, 128 ) 129 ); 128 130 $post_types = array_merge( $post_types, array( 'post', 'page', 'revision' ) ); 129 $supported = array();131 $supported = array(); 130 132 foreach ( $post_types as $post_type ) { 131 133 if ( post_type_supports( $post_type, 'wps_subtitle' ) ) { … … 141 143 * @since 2.3 142 144 * 143 * @param string 145 * @param string $post_type Post Type. 144 146 * @return boolean 145 147 */ 146 148 public static function is_supported_post_type( $post_type ) { 147 149 $post_types = self::get_supported_post_types(); 148 if ( in_array( $post_type, $post_types ) ) {150 if ( in_array( $post_type, $post_types ) ) { 149 151 return true; 150 152 } … … 159 161 * @uses WP_Subtitle::get_subtitle() 160 162 * 161 * @param int|object 163 * @param int|object $post Post ID or object. 162 164 * @return string The filtered subtitle meta value. 163 165 */ … … 178 180 * @uses WP_Subtitle::get_raw_subtitle() 179 181 * 180 * @param int|object 182 * @param int|object $post Post ID or object. 181 183 * @return string The subtitle meta value. 182 184 */ … … 195 197 * @internal 196 198 * 197 * @param int $postPost ID.199 * @param int Post ID. 198 200 * @return string The subtitle meta key. 199 201 */ -
wp-subtitle/tags/3.4.1/wp-subtitle.php
r2712645 r2713271 32 32 */ 33 33 34 require_once ( plugin_dir_path( __FILE__ ) . 'plugin/plugin.php' );34 require_once;
Note: See TracChangeset
for help on using the changeset viewer.