Changeset 780430
- Timestamp:
- 09/30/2013 04:33:11 PM (12 years ago)
- Location:
- prepare-new-version/trunk
- Files:
-
- 5 edited
-
include/admin.php (modified) (6 diffs)
-
prepare_new_version.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
template/duplicata_meta_box.php (modified) (2 diffs)
-
template/submit_meta_box.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
prepare-new-version/trunk/include/admin.php
r778230 r780430 39 39 */ 40 40 public static function handle_action() { 41 if( !isset( $_GET[PNV_ACTION_NAME] ) || !isset( $_GET[' ID'] ) || !check_admin_referer( PNV_ACTION_NONCE) )42 return; 43 44 $source = get_post( $_GET[' ID'] );41 if( !isset( $_GET[PNV_ACTION_NAME] ) || !isset( $_GET['post'] ) || !check_admin_referer( PNV_ACTION_NONCE . '_' . $_GET[PNV_ACTION_NAME] . '_' . $_GET['post'] ) ) 42 return; 43 44 $source = get_post( $_GET['post'] ); 45 45 $post_types = PNV_Option::get_post_types(); 46 46 47 47 // Check post type 48 48 if( !in_array( $source->post_type, $post_types ) ) 49 return; 50 51 $post_type_object = get_post_type_object( $source->post_type ); 52 53 // Check user rights on that post 54 if( !current_user_can( $post_type_object->cap->edit_post, $source->ID ) ) 49 55 return; 50 56 … … 59 65 break; 60 66 case PNV_ERASE_ACTION: 61 $destination = get_post( PNV::get_original( $_GET[' ID'] ) );67 $destination = get_post( PNV::get_original( $_GET['post'] ) ); 62 68 $post_id = PNV::erase_content( $source, $destination, $_GET[PNV_ACTION_NAME] ); 63 69 break; … … 96 102 // If we are on a duplicata, remove default submit meta box and replace it with our box 97 103 if( PNV::is_duplicata( $post->ID ) ) { 98 remove_meta_box( 'submitdiv', $current_ screen->post_type, 'side' );99 add_meta_box( 'pnv_submit_meta_box', PNV_STR_PUBLISH_META_BOX_TITLE, array( __CLASS__, 'submit_meta_box' ), $current_ screen->post_type, 'side', 'core' );104 remove_meta_box( 'submitdiv', $current_post_type, 'side' ); 105 add_meta_box( 'pnv_submit_meta_box', PNV_STR_PUBLISH_META_BOX_TITLE, array( __CLASS__, 'submit_meta_box' ), $current_post_type, 'side', 'core' ); 100 106 101 107 // Replace "duplicates" meta box title … … 112 118 $post = get_post(); 113 119 $original = PNV::get_original(); 114 $action_url = PNV::get_action_url( $post );115 120 116 121 require PNV_COMPLETE_PATH . '/template/duplicata_meta_box.php'; … … 123 128 $post = get_post(); 124 129 $original = PNV::get_original(); 125 $action_url = PNV::get_action_url( $post );126 130 127 131 require PNV_COMPLETE_PATH . '/template/submit_meta_box.php'; … … 357 361 continue; 358 362 359 $index = count( $messages[$post_type] );363 $index = !empty( $messages[$post_type] ) ? count( $messages[$post_type] ) : 0; 360 364 $messages[$post_type][$index] = PNV_STR_MESSAGE_DUPLICATE . ' <a href="' . esc_url( add_query_arg( array( 'post' => $original, 'action' => 'edit' ), admin_url( 'post.php' ) ) ) . '">' . get_the_title( $original ) . '</a>'; 361 365 -
prepare-new-version/trunk/prepare_new_version.php
r778368 r780430 7 7 * Author URI: http://www.globalis-ms.com 8 8 * 9 * Version: 0.9 9 * Version: 0.9.1 10 10 * Requires at least: 3.6.0 11 11 * Tested up to: 3.6 … … 43 43 add_action( 'init', array( __CLASS__, 'init' ) ); 44 44 add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); 45 add_filter( 'post_type_link', array( __CLASS__, 'post_type_link' ), 10, 4 ); 46 add_filter( 'post_link', array( __CLASS__, 'post_link' ), 10, 3 ); 47 add_filter( 'page_link', array( __CLASS__, 'page_link' ), 10, 3 ); 45 48 } 46 49 … … 216 219 } 217 220 218 $destination = apply_filters( ' PNV_erase_content_destination', $destination, $source, $duplicate);221 $destination = apply_filters( 'pnv_erase_content_destination', $destination, $source, $action ); 219 222 220 223 $post_id = wp_insert_post( $destination ); … … 279 282 * Return URL where actions have to be sent 280 283 */ 281 public static function get_action_url( $post ) {282 $action_url = add_query_arg( array( ' ID' => $post->ID, 'action' => 'edit', 'post' => $post->ID ), admin_url( '/post.php' ) );283 $action_url = wp_nonce_url( $action_url, PNV_ACTION_NONCE );284 public static function get_action_url( $post, $action = PNV_DUPLICATE_ACTION ) { 285 $action_url = add_query_arg( array( 'action' => 'edit', 'post' => $post->ID ), admin_url( '/post.php' ) ); 286 $action_url = wp_nonce_url( $action_url, PNV_ACTION_NONCE . '_' . $action . '_' . $post->ID ); 284 287 285 288 return $action_url; 289 } 290 291 /** 292 * Filter Custom Post Types permalinks 293 */ 294 public static function post_type_link( $permalink, $post, $leavename, $sample ) { 295 return self::_post_link( $permalink, $post ); 296 } 297 298 /** 299 * Filter 'post' type permalinks 300 */ 301 public static function post_link( $permalink, $post, $leavename ) { 302 return self::_post_link( $permalink, $post ); 303 } 304 305 /** 306 * Filter 'page' type permalinks 307 */ 308 public static function page_link( $permalink, $post_id, $sample ) { 309 return self::_post_link( $permalink, get_post( $post_id ) ); 310 } 311 312 /** 313 * Filter a permalink and always return a shortlink for a 'duplicata' status: 314 * - we don't need a permalink for that status 315 * - a shortlink won't work since WordPress will redirect to permalink because this status is not draft or pending 316 * - we need a shortlink for the preview 317 */ 318 protected static function _post_link( $permalink, $post ) { 319 if( PNV::is_duplicata( $post ) && in_array( $post->post_type, PNV_Option::get_post_types() ) ) { 320 switch( $post->post_type ) { 321 case 'page': 322 $permalink = add_query_arg( array( 'page_id' => $post->ID ), '' ); 323 break; 324 default: 325 $permalink = add_query_arg( array( 'post_type' => $post->post_type, 'p' => $post->ID ), '' ); 326 } 327 $permalink = home_url( $permalink ); 328 } 329 330 return $permalink; 286 331 } 287 332 } -
prepare-new-version/trunk/readme.txt
r778239 r780430 4 4 Requires at least: 3.5 5 5 Tested up to: 3.6.1 6 Stable tag: 0.9 6 Stable tag: 0.9.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
prepare-new-version/trunk/template/duplicata_meta_box.php
r778230 r780430 18 18 </ul> 19 19 <p id="prepare-actions"> 20 <a href="<?php echo add_query_arg( PNV_ACTION_NAME, PNV_DUPLICATE_ACTION, $action_url); ?>" id="duplicate" class="button <?php echo !empty( $original ) ? '' : 'button-primary button-large'; ?>"><?php echo PNV_STR_DUPLICATE_BUTTON; ?></a><br/>20 <a href="<?php echo add_query_arg( PNV_ACTION_NAME, PNV_DUPLICATE_ACTION, PNV::get_action_url( $post ) ); ?>" id="duplicate" class="button <?php echo !empty( $original ) ? '' : 'button-primary button-large'; ?>"><?php echo PNV_STR_DUPLICATE_BUTTON; ?></a><br/> 21 21 22 22 <?php … … 30 30 } 31 31 ?> 32 <a href="<?php echo add_query_arg( PNV_ACTION_NAME, PNV_COPY_ACTION , $action_url); ?>" id="copy"<?php echo $class; ?>><?php echo $title; ?></a>32 <a href="<?php echo add_query_arg( PNV_ACTION_NAME, PNV_COPY_ACTION , PNV::get_action_url( $post, PNV_COPY_ACTION ) ); ?>" id="copy"<?php echo $class; ?>><?php echo $title; ?></a> 33 33 </p> -
prepare-new-version/trunk/template/submit_meta_box.php
r778230 r780430 19 19 <div id="publishing-action"> 20 20 <span class="spinner"></span> 21 <a href="<?php echo add_query_arg( PNV_ACTION_NAME, PNV_ERASE_ACTION, $action_url); ?>" id="erase" class="button button-primary button-large"><?php echo PNV_STR_ERASE_BUTTON; ?></a>21 <a href="<?php echo add_query_arg( PNV_ACTION_NAME, PNV_ERASE_ACTION, PNV::get_action_url( $post, PNV_ERASE_ACTION ) ); ?>" id="erase" class="button button-primary button-large"><?php echo PNV_STR_ERASE_BUTTON; ?></a> 22 22 </div> 23 23 <div class="clear"></div>
Note: See TracChangeset
for help on using the changeset viewer.