0 ) { if ( ! is_null( $_GET['edit-ad'] ) && $existing_ads[ $_GET['edit-ad'] ] ) { $_SESSION['advertise-world-wp-plugin-editing-ad-id'] = $_GET['edit-ad']; } elseif ( $_SESSION['advertise-world-wp-plugin-editing-ad-id'] != null ) { return $_SESSION['advertise-world-wp-plugin-editing-ad-id']; } else { end( $existing_ads ); $last_id = (int) key( $existing_ads ); $_SESSION['advertise-world-wp-plugin-editing-ad-id'] = $last_id + 1; } } else { $_SESSION['advertise-world-wp-plugin-editing-ad-id'] = 0; } return $_SESSION['advertise-world-wp-plugin-editing-ad-id']; } /** * Displays dropdown box of available ad spaces. * * @since 1.0.0 */ function advertise_world_wp_options_new_ad_title() { ?>
Advertise World Ad Space Name:
Preferred Height For Responsive Ad:
Use Fixed Size Ad:
$registered_sidebar ) { if ( ! ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) ) { $theme_sidebars[ $sidebar ] = $registered_sidebar; } } $chosen_type = ''; if ( is_array( $existing_ads[ $_SESSION['advertise-world-wp-plugin-editing-ad-id'] ] ) && array_key_exists( "type", $existing_ads[ $_SESSION['advertise-world-wp-plugin-editing-ad-id'] ] ) ) { $chosen_type = $existing_ads[ $_SESSION['advertise-world-wp-plugin-editing-ad-id'] ]['type']; } echo ''; echo ''; echo ''; ?>
Ad Placement Area
'; advertise_world_wp_options_display_placements( $options, $chosen_type ); echo '
Theme Specific Areas:
'; $options = Array(); foreach ( $theme_sidebars as $theme_sidebar ) { array_push( $options, array( $theme_sidebar['name'], $theme_sidebar['id'] ) ); } advertise_world_wp_options_display_placements( $options, $chosen_type ); echo '
'; echo ''; echo ' '; echo $placement[0]; echo ''; echo ' '; } } /** * Returns advertise-world-wp-options-main-account field content * * @since 1.0.0 */ function advertise_world_wp_options_new_ad_placement() { require_once( ABSPATH . 'wp-admin/includes/widgets.php' ); $options = Array( Array( 'header', 'advertise_world_wp_options_default_above_below' ), Array( 'content', 'advertise_world_wp_options_default_above_below' ), Array( 'footer', 'advertise_world_wp_options_default_above_below' ), Array( 'post', 'advertise_world_wp_options_default_above_below' ) ); $theme_sidebars = array(); foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar => $registered_sidebar ) { if ( ! ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) ) { $theme_sidebars[ $sidebar ] = $registered_sidebar; } } foreach ( $theme_sidebars as $theme_sidebar ) { array_push( $options, array( $theme_sidebar['id'], 'advertise_world_wp_options_default_widget_placement' ) ); } echo '' . '' . '' . '' . '' . ''; echo '
Position within specified area
'; echo ''; echo '
'; } /** * Displays placement radio options for a specified injected ad. * * @since 1.0.0 * * @param string $id Type value */ function advertise_world_wp_options_default_above_below( $id ) { $existing_ads = get_option( 'advertise-world-wp-options-new-ad' ); if ( ! is_array( $existing_ads ) ) { $existing_ads = array(); } ?>
$advert ) { if ( ! array_key_exists( 'title', $advert ) || $advert['title'] === '' ) { add_settings_error( 'advertise-world-new-ad-title-invalid', 'settings_updated', 'You must select an ad space name for your ad space to continue!', 'error' ); continue; } if ( ! array_key_exists( 'type', $advert ) ) { add_settings_error( 'advertise-world-new-ad-type-invalid', 'settings_updated', 'You must select a type for your ad space to continue!', 'error' ); continue; } // Default to shortest for backward compatibility if ( ! array_key_exists( 'height-choice', $advert ) ) { $advert['height-choice'] = 'shortest'; } // Default to responsive ads for backward compatibility if ( ! array_key_exists( 'fixed-size', $advert ) ) { $advert['fixed-size'] = 'responsive'; } $theme_sidebars = array(); foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar => $registered_sidebar ) { if ( ! ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) ) { array_push( $theme_sidebars, $registered_sidebar['id'] ); } } if ( in_array( $advert['type'], $theme_sidebars ) ) { add_settings_error( 'advertise-world-new-ad-widget-placement-invalid', 'settings_updated', 'Please follow the instructions to correctly create a Advertise World widget!', 'error' ); continue; } if ( ! array_key_exists( 'placement', $advert ) ) { add_settings_error( 'advertise-world-new-ad-placement-invalid', 'settings_updated', 'You must select a placement for your ad space to continue!', 'error' ); continue; } $was_succuessfull_addition = true; $valid[ $id ] = $advert; } } if ( $input['delete'] ) { foreach ( $input['delete'] as $id ) { unset( $valid[ $id ] ); } } if ( true == $was_succuessfull_addition ) { $_SESSION['advertise-world-wp-plugin-editing-ad-id'] = null; } return $valid; }