', 'adredux'); echo $headercode; } } public function adredux_footer_codes() { $footercode = adredux_get_option('adredux_footer_codes'); if ( !isset ($footercode) || ($footercode == '') ) return; _e ( '', 'adredux'); echo $footercode; } public function adredux_pagelevel_adcode() { $pagelevelad = adredux_get_option('adredux_pagelevel_adcode', ''); if ( !isset ($pagelevelad) || ($pagelevelad == '') ){ return; } else { $showads = adredux_get_option('adredux_showads')[0]; if ( isset ($showads) && ($showads == '0') ) { return; } elseif ( isset ($showads) && ($showads == '1') && is_user_logged_in() ) { return; } elseif ( isset ($showads) && ($showads == '2') && is_user_logged_in() && current_user_can( 'edit_posts' ) ) { return; } else { $ad_page = adredux_get_option('ad_page')[0]; $exclude_categories = adredux_get_option('exclude_categories', array('0')); $exclude_tags = adredux_get_option('exclude_tags', array('0')); if ( (is_singular()) && ( ($ad_page == 'posts') || ($ad_page == 'both') ) && (!in_category($exclude_categories)) && (!has_tag($exclude_tags)) ){ _e ( '', 'adredux'); echo $pagelevelad; } elseif ( (is_page()) && ( ($ad_page == 'pages') || ($ad_page == 'both') ) ) { _e ( '', 'adredux'); echo $pagelevelad; } else { return; } } } } public function adredux_create_settings_page() { // Add the menu item and page $page_title = __('Ad Redux', 'adredux'); $menu_title = __('Ad Redux', 'adredux'); $capability = 'manage_options'; $slug = 'adredux_settings'; $callback = array( $this, 'adredux_settings_page_content' ); $icon = 'dashicons-admin-plugins'; $position = 100; add_menu_page( $page_title, $menu_title, $capability, $slug, $callback, $icon, $position ); add_submenu_page( $slug, __('Ad Redux Settings', 'adredux'), __('General Settings', 'adredux'), $capability, $slug, $callback ); add_submenu_page( $slug, __('About Ad Redux', 'adredux'), __('About Ad Redux', 'adredux'), $capability, 'adredux_settings_ads', array( $this, 'adredux_settings_adpage_content' ) ); } public function adredux_settings_page_content() {?>
Here is the raw data as saved in the WordPress options settings of your website. All of your Ad Redux settings are saved in WordPress options, in the adredux_settings option.
','adredux'); ?>
<p></p> in any of the ad codes when using the second para ad location.', 'adredux'),
'default' => '',
);
$adfields[] =
array(
'uid' => 'adcode_location_'.$adslot,
'label' => __('Display Location', 'adredux'),
'section' => 'adredux_adcode_'.$adslot,
'type' => 'select',
'options' => array(
'before-content' => __('Before Content', 'adredux'),
'after-para-one' => __('Content - After First Paragraph', 'adredux'),
'after-para-two' => __('Content - After Second Paragraph', 'adredux'),
'after-para-three' => __('Content - After Third Paragraph', 'adredux'),
'after-para-secondlast' => __('Content - After Second Last Paragraph', 'adredux'),
'mid-content' => __('Mid Content', 'adredux'),
'after-content' => __('After Content', 'adredux'),
),
'placeholder' => '',
'helper' => '',
'supplimental' => '',
'default' => array('before-content')
);
$adfields[] =
array(
'uid' => 'adcode_align_'.$adslot,
'label' => __('Alignment', 'adredux'),
'section' => 'adredux_adcode_'.$adslot,
'type' => 'select',
'options' => array(
'alignleft' => __('Left', 'adredux'),
'alignright' => __('Right', 'adredux'),
'aligncenter' => __('Center', 'adredux'),
'leftright' => __('Random (Left/Right)', 'adredux'),
'random' => __('Random (All)', 'adredux'),
),
'placeholder' => '',
'helper' => '',
'supplimental' => '',
'default' => array('center')
);
$adfields[] =
array(
'uid' => 'adcode_maxwidth_'.$adslot,
'label' => __('Max Width', 'adredux'),
'section' => 'adredux_adcode_'.$adslot,
'type' => 'text',
'placeholder' => '',
'helper' => __('Pixels', 'adredux'),
'supplimental' => __('Set the maximum width (400px recommended) for responsive ads. Leave blank to use container width.', 'adredux'),
'default' => ''
);
}
//var_dump($adfields);
foreach( $adfields as $key=>$adfield ){
add_settings_field( $adredux_settings_name.'['.$adfield['uid'].']', $adfield['label'], array( $this, 'field_callback' ), 'adredux_settings', $adfield['section'], $adfield );
}
register_setting( 'adredux_settings', $adredux_settings_name );
register_setting( 'adredux_settings_ads', $adredux_settings_name );
}
public function field_callback( $arguments ) {
//Settings Name Must Be Same As Above
$adredux_settings_name = 'adredux_settings';
$settings = get_option( $adredux_settings_name );
if ( isset( $settings[$arguments['uid']] ) ) {
$value = $settings[$arguments['uid']];
} else {
$value = $arguments['default'];
}
switch( $arguments['type'] ){
case 'password':
case 'text':
printf( '', $adredux_settings_name.'['.$arguments['uid'].']', $arguments['type'], $arguments['placeholder'], $value );
break;
case 'number':
printf( '', $adredux_settings_name.'['.$arguments['uid'].']', $arguments['type'], $arguments['placeholder'], $value );
break;
case 'textarea':
printf( '', $adredux_settings_name.'['.$arguments['uid'].']', $arguments['placeholder'], $value );
break;
case 'select':
case 'multiselect':
if( ! empty ( $arguments['options'] ) && is_array( $arguments['options'] ) ){
$attributes = '';
$options_markup = '';
foreach( $arguments['options'] as $key => $label ){
$options_markup .= sprintf( '', $key, selected( $value[ array_search( $key, $value, false ) ], $key, false ), $label );
}
if( $arguments['type'] === 'multiselect' ){
$attributes = ' multiple="multiple" ';
}
printf( '', $adredux_settings_name.'['.$arguments['uid'].']', $attributes, $options_markup );
}
break;
case 'radio':
case 'checkbox':
if( ! empty ( $arguments['options'] ) && is_array( $arguments['options'] ) ){
$options_markup = '';
$iterator = 0;
foreach( $arguments['options'] as $key => $label ){
$iterator++;
$options_markup .= sprintf( '%s
', $supplimental ); } } } new Adredux_Plugin();