Ticket #20659: wp-shortcode-desc-1.patch
File wp-shortcode-desc-1.patch, 4.3 KB (added by , 11 years ago) |
---|
-
wp-includes/shortcodes.php
128 128 } 129 129 130 130 /** 131 * Gets descriptions of all shortcodes. 132 * 133 * @uses $shortcode_tags 134 * 135 * @return array An array containing all shortcodes and description of them and its attributes 136 */ 137 function get_shortcode_descriptions() { 138 global $shortcode_tags; 139 140 $descriptions = array(); 141 142 foreach ( $shortcode_tags as $shortcode => $func ) { 143 $descriptions[$shortcode] = get_shortcode_description( $shortcode ); 144 } 145 146 $descriptions = array_filter($descriptions); 147 ksort($descriptions); 148 149 return $descriptions; 150 } 151 152 /** 153 * Gets description of a shortcode. 154 * 155 * @uses $shortcode_tags 156 * 157 * @param string $shortcode The namn of the shortcode to get the description of 158 * @return array An array containing descriptions of the shortcode and its attributes 159 */ 160 function get_shortcode_description($shortcode) { 161 global $shortcode_tags; 162 163 if ( !isset( $shortcode_tags[$shortcode] ) ) { 164 return false; 165 } 166 167 $description = array( 168 'shortcode' => $shortcode, 169 'description' => '', 170 'atts' => array(), 171 ); 172 173 return apply_filters( 'shortcode_description', $description, $shortcode ); 174 } 175 176 /** 131 177 * Search content for shortcodes and filter shortcodes through their hooks. 132 178 * 133 179 * If there are no shortcode tags defined, then the content will be returned -
wp-includes/media.php
1062 1062 1063 1063 // After a post is saved, cache oEmbed items via AJAX 1064 1064 add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') ); 1065 1066 // Describe shortcode in post form 1067 add_filter( 'shortcode_description', array(&$this, 'describe_shortcode') ); 1065 1068 } 1066 1069 1067 1070 /** … … 1097 1100 return $content; 1098 1101 } 1099 1102 1103 function describe_shortcode( $description ) { 1104 if ( isset($description['shortcode']) && $description['shortcode'] == 'embed' ) { 1105 $description['description'] = 'Embeds the wrapped URL'; 1106 $description['atts'] = array( 1107 'width' => 'Max width of the embed', 1108 'height' => 'Max height of the embed', 1109 ); 1110 } 1111 return $description; 1112 } 1113 1100 1114 /** 1101 1115 * If a post/page was saved, then output JavaScript to make 1102 1116 * an AJAX request that will call WP_Embed::cache_oembed(). -
wp-admin/includes/meta-boxes.php
381 381 } 382 382 383 383 /** 384 * Display descriptions of shortcodes. 385 * 386 * @param object $post 387 */ 388 function post_shortcodedesc_meta_box($post) { 389 $shortcodes = get_shortcode_descriptions(); 390 391 $descriptions = '<ul>'; 392 foreach ($shortcodes as $shortcodes) { 393 $descriptions .= "\n\t<li>\n\t\t<strong>[" . esc_html($shortcodes['shortcode']) . "]</strong> "; 394 if (!empty($shortcodes['description'])) { 395 $descriptions .= '- ' . esc_html($shortcodes['description']); 396 } 397 if (!empty($shortcodes['atts'])) { 398 $descriptions .= "\n\t\t<ul>"; 399 foreach ($shortcodes['atts'] as $attribute => $attributeDescription) { 400 $descriptions .= "\n\t\t\t<li><strong>" . esc_html($attribute) . "</strong> "; 401 if (!empty($attributeDescription)) { 402 $descriptions .= '- ' . esc_html($attributeDescription); 403 } 404 } 405 $descriptions .= "\n\t\t</ul>"; 406 } 407 $descriptions .= "\n\t</li>"; 408 } 409 $descriptions .= '</ul>'; 410 411 echo $descriptions; 412 } 413 414 415 /** 384 416 * Display trackback links form fields. 385 417 * 386 418 * @since 2.6.0 -
wp-admin/edit-form-advanced.php
130 130 if ( post_type_supports($post_type, 'excerpt') ) 131 131 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); 132 132 133 if ( post_type_supports($post_type, 'editor') ) 134 add_meta_box('shortcodedesc', __('Shortcodes'), 'post_shortcodedesc_meta_box', null, 'side', 'core'); 135 133 136 if ( post_type_supports($post_type, 'trackbacks') ) 134 137 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core'); 135 138