Changeset 1696624
- Timestamp:
- 07/15/2017 06:30:17 AM (9 years ago)
- Location:
- listolicious/trunk
- Files:
-
- 2 edited
-
listolicious.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
listolicious/trunk/listolicious.php
r1586081 r1696624 3 3 Plugin Name: Listolicious 4 4 Description: The shortcode displays a movie list in the style of Mubi 5 Version: 1. 2.15 Version: 1.3 6 6 Author: Daniel Hånberg Alonso 7 7 Author URI: http://webbilicious.se … … 57 57 if ( is_admin() ) { 58 58 59 add_action( 'save_post', array( $this, 'save_details') );60 59 add_filter( 'manage_edit-movies_columns', array( $this, 'edit_columns' ) ); 60 add_filter( 'manage_edit-movies_sortable_columns', array( $this, 'sortable_columns' ) ); 61 add_action( 'pre_get_posts', array( $this, 'sort_posts' ), 1 ); 61 62 add_action( 'manage_posts_custom_column', array( $this, 'add_columns' ) ); 62 63 add_action( 'quick_edit_custom_box', array( $this, 'quickedit' ), 10, 2 ); 63 64 add_action( 'admin_enqueue_scripts', array( $this, 'quickedit_script' ), 10, 1 ); 64 65 add_action( 'save_post', array( $this, 'save_details'), 10, 1 ); 65 66 } 66 67 } … … 193 194 global $post; 194 195 196 wp_nonce_field('save_listolicious', 'movie_edit_nonce'); 197 195 198 $custom = get_post_custom($post->ID); 196 199 $listo_director = isset( $custom["listo_director"][0] ) ? $custom["listo_director"][0] : ''; … … 198 201 $listo_url = isset( $custom["listo_url"][0] ) ? $custom["listo_url"][0] : ''; 199 202 200 wp_nonce_field( 'save_listolicious', 'movie_edit_nonce' );201 203 ?> 202 204 <p><label><?php _e('Director', 'listolicious'); ?>:</label><br /> … … 214 216 * @since 1.0 215 217 */ 216 function save_details( ){218 function save_details($post_id){ 217 219 global $post; 218 220 219 if ( ! empty( $_POST ) && check_admin_referer( 'save_listolicious', 'movie_edit_nonce' ) ) { 220 221 $id = ( isset( $post->ID ) ? get_the_ID() : NULL ); 221 if ( ! empty( $_POST ) ) { 222 223 //check nonce set 224 if(!isset($_POST['movie_edit_nonce'])){ 225 return false; 226 } 227 228 //verify nonce 229 if(!wp_verify_nonce($_POST['movie_edit_nonce'], 'save_listolicious')){ 230 return false; 231 } 232 222 233 $listo_director = isset( $_POST['listo_director'] ) ? sanitize_text_field( $_POST['listo_director'] ) : ''; 223 234 $listo_year = isset( $_POST['listo_year'] ) ? sanitize_text_field( $_POST['listo_year'] ) : ''; 224 235 $listo_url = isset( $_POST['listo_url'] ) ? sanitize_text_field( $_POST['listo_url'] ) : ''; 225 236 226 update_post_meta( $id, "listo_director", $listo_director ); 227 update_post_meta( $id, "listo_year", $listo_year ); 228 update_post_meta( $id, "listo_url", $listo_url ); 237 update_post_meta( $post_id, "listo_director", $listo_director ); 238 update_post_meta( $post_id, "listo_year", $listo_year ); 239 update_post_meta( $post_id, "listo_url", $listo_url ); 240 229 241 } 230 242 } … … 348 360 * @since 1.0 349 361 */ 350 function add_columns($column ){362 function add_columns($columns){ 351 363 global $post; 352 364 353 switch ($column ) {365 switch ($columns) { 354 366 case "director": 355 367 $custom = get_post_custom(); … … 367 379 368 380 /** 381 * The following filter makes the custom columns sortable. 382 * 383 * @since 1.3 384 */ 385 function sortable_columns( $sortable_columns ) { 386 387 $sortable_columns[ 'director' ] = 'director'; 388 $sortable_columns[ 'year' ] = 'year'; 389 390 return $sortable_columns; 391 } 392 393 /** 394 * The following action makes the custom columns sortable. 395 * 396 * @since 1.3 397 */ 398 function sort_posts( $query ) { 399 400 /** 401 * We only want our code to run in the main WP query 402 * AND if an orderby query variable is designated. 403 */ 404 if ( $query->is_main_query() && ( $orderby = $query->get( 'orderby' ) ) ) { 405 406 switch( $orderby ) { 407 408 case 'director': 409 410 $query->set( 'meta_key', 'listo_director' ); 411 $query->set( 'orderby', 'meta_value' ); 412 413 break; 414 415 case 'year': 416 417 $query->set( 'meta_key', 'listo_year' ); 418 $query->set( 'orderby', 'meta_value' ); 419 420 break; 421 422 } 423 } 424 } 425 426 427 /** 369 428 * Adds quickedit button for editing in list view 370 429 * … … 372 431 */ 373 432 function quickedit($column_name, $post_type) { 374 static $printNonce = TRUE; 375 if ( $printNonce ) { 376 $printNonce = FALSE; 377 wp_nonce_field( plugin_basename( __FILE__ ), 'movie_edit_nonce' ); 378 } 433 434 wp_nonce_field( 'save_listolicious', 'movie_edit_nonce' ); 379 435 380 436 ?> -
listolicious/trunk/readme.txt
r1586081 r1696624 4 4 Tags: shortcode, custom post type, list, movie 5 5 Requires at least: 4.5.3 6 Tested up to: 4. 7.27 Stable tag: 1. 2.16 Tested up to: 4.8 7 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.