'Usage', 'id' => 'adsforwp_group_shortcode', 'type' => 'text', 'attributes' => array( 'readonly' => 'readonly', 'disabled' => 'disabled', 'class' => 'afw_manual_ads_type', ), ), array( 'label' => 'Sorting', 'id' => 'adsforwp_group_type', 'type' => 'radio', 'default' => 'rand', 'options' => array( 'rand'=>'Random ads', 'ordered'=>'Ordered ads ', ), ), array( 'label' => 'Refresh Type', 'id' => 'adsforwp_refresh_type', 'type' => 'select', 'options' => array( 'on_load' => 'On Reload', 'on_interval' => 'Auto Refresh' ) ), array( 'id' => 'adsforwp_group_ref_interval_sec', 'type' => 'number', ), array( 'label' => 'Ads', 'id' => 'adsforwp_ads', 'class' => 'afw-option afw-option-group-ads', 'type' => 'div', ), array( 'label' => 'Ad New', 'id' => 'adsforwp_group_ad_list', 'type' => 'select', ), ); public function __construct() { $all_ads = get_posts( array( 'post_type' => 'adsforwp', 'posts_per_page' => -1, 'post_status' => 'publish', ) ); foreach($all_ads as $ad){ $this->ads_list[] = array( 'ad_id' => $ad->ID, 'ad_name' => $ad->post_title ); } add_action( 'add_meta_boxes', array( $this, 'adsforwp_add_meta_boxes' ) ); add_action( 'save_post', array( $this, 'adsforwp_save_fields' ) ); } public function adsforwp_add_meta_boxes() { foreach ( $this->screen as $single_screen ) { add_meta_box( 'adgroup', esc_html__( 'Ad Group', 'ads-for-wp' ), array( $this, 'adsforwp_meta_box_callback' ), $single_screen, 'advanced', 'low' ); } } public function adsforwp_meta_box_callback( $post ) { wp_nonce_field( 'adgroup_data', 'adgroup_nonce' ); $this->adsforwp_field_generator( $post ); } public function adsforwp_field_generator( $post ) { $output = ''; foreach ( $this->meta_fields as $meta_field ) { $id =''; $attributes =''; $metafieldlabel =''; if(array_key_exists('id', $meta_field)){ $id =$meta_field['id']; } if(array_key_exists('label', $meta_field)){ $metafieldlabel =$meta_field['label']; } $label = ''; $meta_value = get_post_meta( $post->ID, $id, true ); if ( empty( $meta_value ) ) { $meta_value = isset($meta_field['default']); } switch ( $meta_field['type'] ) { case 'checkbox': $input = sprintf( '', $meta_value === '1' ? 'checked' : '', $id, $id ); break; case 'div': $this->added_ad_list = $meta_value; $input = '
'; $input .= ''. esc_html__('Add More...', 'ads-for-wp').''; break; case 'radio': if($meta_value === 'ordered' || $meta_value === 'rand'){ $default_val = $meta_value; }else{ $default_val = $meta_field['default']; } $input = ''; break; case 'select': switch ($id) { case 'adsforwp_group_ad_list': $input = sprintf( ''. esc_html__('You have added all ads', 'ads-for-wp').''. esc_html__('Refresh ads on the same spot', 'ads-for-wp').'
' . ''.esc_html__('On AMP ads will be shown only on reload.', 'ads-for-wp').' '.esc_html__('why?', 'ads-for-wp').'
', $meta_field['type'] !== 'color' ? '' : '', $id, $id, $meta_field['type'], $meta_value ); break; default: if(isset($meta_field['attributes'])){ foreach ( $meta_field['attributes'] as $key => $value ) { $attributes .= $key."=".'"'.$value.'"'.' '; } } $input = sprintf( '', $meta_field['type'] !== 'color' ? '' : '', $id, $id, $meta_field['type'], $meta_value, $attributes ); break; } } $output .= $this->adsforwp_format_rows( $label, $input ); } $common_function_obj = new adsforwp_admin_common_functions(); $allowed_html = $common_function_obj->adsforwp_expanded_allowed_tags(); echo '