ad-ajax.php
11 years ago
ad-model.php
11 years ago
ad-select.php
11 years ago
ad.php
11 years ago
ad_ajax_callbacks.php
11 years ago
ad_group.php
11 years ago
ad_placements.php
11 years ago
ad_type_abstract.php
11 years ago
ad_type_content.php
11 years ago
ad_type_plain.php
11 years ago
plugin.php
11 years ago
widget.php
11 years ago
ad_ajax_callbacks.php
84 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Advanced Ads. |
| 5 | * |
| 6 | * @package Advanced_Ads |
| 7 | * @author Thomas Maier <thomas.maier@webgilde.com> |
| 8 | * @license GPL-2.0+ |
| 9 | * @link http://webgilde.com |
| 10 | * @copyright 2013 Thomas Maier, webgilde GmbH |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * This class is used to bundle all ajax callbacks |
| 15 | * |
| 16 | * @package Advanced_Ads_Ajax_Callbacks |
| 17 | * @author Thomas Maier <thomas.maier@webgilde.com> |
| 18 | */ |
| 19 | class Advads_Ad_Ajax_Callbacks { |
| 20 | |
| 21 | public function __construct() { |
| 22 | |
| 23 | // NOTE: admin only! |
| 24 | add_action( 'wp_ajax_load_content_editor', array( $this, 'load_content_editor' ) ); |
| 25 | add_action( 'wp_ajax_load_ad_parameters_metabox', array( $this, 'load_ad_parameters_metabox' ) ); |
| 26 | add_action( 'wp_ajax_advads-terms-search', array( $this, 'search_terms' ) ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * load content of the ad parameter metabox |
| 31 | * |
| 32 | * @since 1.0.0 |
| 33 | */ |
| 34 | public function load_ad_parameters_metabox() { |
| 35 | |
| 36 | $types = Advanced_Ads::get_instance()->ad_types; |
| 37 | $type = $_REQUEST['ad_type']; |
| 38 | $ad_id = absint( $_REQUEST['ad_id'] ); |
| 39 | if ( empty($ad_id) ) { wp_die(); } |
| 40 | |
| 41 | $ad = new Advads_Ad( $ad_id ); |
| 42 | |
| 43 | if ( ! empty($types[$type]) && method_exists( $types[$type], 'render_parameters' ) ) { |
| 44 | $types[$type]->render_parameters( $ad ); |
| 45 | ?> |
| 46 | <div id="advanced-ads-ad-parameters-size"> |
| 47 | <p><?php _e( 'size:', ADVADS_SLUG ); ?></p> |
| 48 | <label><?php _e( 'width', ADVADS_SLUG ); ?><input type="number" size="4" maxlength="4" value="<?php echo isset($ad->width) ? $ad->width : 0; ?>" name="advanced_ad[width]">px</label> |
| 49 | <label><?php _e( 'height', ADVADS_SLUG ); ?><input type="number" size="4" maxlength="4" value="<?php echo isset($ad->height) ? $ad->height : 0; ?>" name="advanced_ad[height]">px</label> |
| 50 | </div> |
| 51 | <?php |
| 52 | } |
| 53 | |
| 54 | wp_die(); |
| 55 | |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * search terms belonging to a specific taxonomy |
| 60 | * |
| 61 | * @sinc 1.4.7 |
| 62 | */ |
| 63 | public function search_terms(){ |
| 64 | $args = array(); |
| 65 | $taxonomy = $_POST['tax']; |
| 66 | $args = array('hide_empty' => false, 'number' => 20); |
| 67 | |
| 68 | if ( !isset( $_POST['search'] ) || $_POST['search'] === '' ) { wp_die(); } |
| 69 | |
| 70 | // if search is an id, search for the term id, else do a full text search |
| 71 | if(0 !== absint($_POST['search'])){ |
| 72 | $args['include'] = array(absint($_POST['search'])); |
| 73 | } else { |
| 74 | $args['search'] = $_POST['search']; |
| 75 | } |
| 76 | |
| 77 | $results = get_terms( $taxonomy, $args ); |
| 78 | // $results = _WP_Editors::wp_link_query( $args ); |
| 79 | echo wp_json_encode( $results ); |
| 80 | echo "\n"; |
| 81 | wp_die(); |
| 82 | } |
| 83 | } |
| 84 |