add_ajax_calls(); } } /** * Wrapper to avoid future fuck-ups and repetitive works (aka DRY!) */ function get_slider_settings( $default = array() ) { return get_option( $this->optionName, $default ); } function update_slider_settings( $settings = array() ) { $return = false; if( !empty( $settings ) ) { $return = update_option( $this->optionName, $settings ); } return $return; } /** * Add all required ajax calls and processing stuff * * @author Fabian Wolf * @package cc2 * @since 2.0 */ function add_ajax_calls() { /** * TODO: We might want to add a user_can() check in here, to avoid possible security holes * @see http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Viewer-Facing_Side */ // save settings add_action( 'wp_ajax_' . $this->classPrefix . 'query', array( $this, 'update_settings') ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'query', array( $this, 'update_settings') ); // show list of slides add_action( 'wp_ajax_' . $this->classPrefix . 'display_slides_list', array( $this, 'display_slides_list') ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'display_slides_list', array( $this, 'display_slides_list') ); // add new slideshow add_action( 'wp_ajax_' . $this->classPrefix . 'add_slideshow', array( $this, 'add_slideshow') ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'add_slideshow', array( $this, 'add_slideshow') ); // add single slide add_action( 'wp_ajax_' . $this->classPrefix . 'add_slide', array( $this, 'add_slide' ) ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'add_slide', array( $this, 'add_slide' ) ); // delete whole slideshow add_action( 'wp_ajax_' . $this->classPrefix . 'delete_slideshow', array( $this, 'delete_slideshow') ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'delete_slideshow', array( $this,'delete_slideshow') ); // delete single slide add_action( 'wp_ajax_' . $this->classPrefix . 'delete_slide', array( $this, 'delete_slide' ) ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'delete_slide', array( $this, 'delete_slide') ); // change order of slides add_action( 'wp_ajax_' . $this->classPrefix . 'slideshow_neworder', array( $this, 'slideshow_neworder' ) ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'slideshow_neworder', array( $this, 'slideshow_neworder' ) ); // safety switch: reset all slideshows add_action( 'wp_ajax_' . $this->classPrefix . 'reset_slideshows', array( $this, 'reset_slideshows' ) ); //add_action( 'wp_ajax_nopriv_' . $this->classPrefix . 'reset_slideshows', array( $this, 'reset_slideshows' ) ); // update post meta fields (aka custom fields) add_action('wp_ajax_save-attachment-compat', array( $this, 'update_media_xtra_fields'), 0, 1); } /** * Processing methods for handling the ajax calls on the server side are all up next * * @author Fabian Wolf * @package cc2 * @since 2.0 */ /** * Update settings */ function update_settings() { // validate data /** * TODO: Validation and sanitization is missing */ if(isset($_POST['select_slides_list'])) { $select_slides_list = $_POST['select_slides_list']; } if(isset($_POST['slideshow_post_type'])) { $slideshow_post_type = $_POST['slideshow_post_type']; } if(isset($_POST['slideshow_taxonomy'])) { $slideshow_taxonomy = $_POST['slideshow_taxonomy']; } if(isset($_POST['slideshow_cat'])) { $slideshow_cat = $_POST['slideshow_cat']; } // update settings //$cc_slider_options = get_option('cc_slider_options', array() ); $cc_slider_options = $this->get_slider_settings(); if(isset($slideshow_post_type)) { $cc_slider_options[$select_slides_list]['query']['post_type'] = $slideshow_post_type; } if(isset($slideshow_taxonomy)) { $cc_slider_options[$select_slides_list]['query']['taxonomy'] = $slideshow_taxonomy; } if(isset($slideshow_cat)) { $cc_slider_options[$select_slides_list]['query']['cat'] = $slideshow_cat; } $this->update_slider_settings( $cc_slider_options ); //$this->update_slider_settings( $cc_slider_options ); die(); } /** * Safety switch, eg. if some of the slideshows got fucked up during tests etc. */ function reset_slideshows() { update_option( $this->optionName, array() ); } /** * Returns the slide list */ function display_slides_list() { $cc_slider_options = $this->get_slider_settings(); if(isset($_POST['slide_list'])) { $slide_list = $_POST['slide_list']; } if(!isset($slide_list)) { return; } if(!isset($cc_slider_options[$slide_list])) { die(); } if( isset($slide_list) && isset($cc_slider_options[$slide_list]) ) { ?>
true, '_builtin' => true ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' ?>