ad_swapper_ad_display_widget // [name] => Ad Swapper Ad Displayer // [widget_options] => Array( // [classname] => widget_ad_swapper_ad_display_widget // [description] => Drag me to the widget area(s) you want to display Ad Swapper Ads in... // ) // [control_options] => Array( // [id_base] => ad_swapper_ad_display_widget // ) // [number] => 2 // [id] => ad_swapper_ad_display_widget-2 // [updated] => // [option_name] => widget_ad_swapper_ad_display_widget // ) // // ------------------------------------------------------------------------- //ob_start() ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $that , '$that' ) ; //$pr = ob_get_clean() ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $instance = Array( // [title] => // [message] => // ) // // ------------------------------------------------------------------------- //ob_start() ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $instance , '$instance' ) ; //$pr .= ob_get_clean() ; // ------------------------------------------------------------------------- // OVERVIEW // ======== // Sadly, the widget settings save functionality built into WordPress // doesn't seem to work. So although the user can "Save" the form we // create here, when the form is re-displayed, the:- // $instance // // (shown above) is supplied with all variables (eg; "title" and // "message", the example above), set to the empty string. // // So we save the settings in ARRAY STORAGE. // ------------------------------------------------------------------------- // ========================================================================= // Init. // ========================================================================= //error_reporting( E_ALL ) ; //ini_set( 'display_errors' , '1' ) ; // ------------------------------------------------------------------------- // $ns = __NAMESPACE__ ; // $fn = __FUNCTION__ ; // ------------------------------------------------------------------------- $ad_slots_dataset_slug = 'ad_swapper_ad_slots' ; $widget_settings_dataset_slug = 'ad_swapper_widget_settings' ; // ========================================================================= // Get this widget instance's settings... // ========================================================================= require_once( dirname( __FILE__ ) . '/widget-settings-support.php' ) ; // ------------------------------------------------------------------------- // greatKiwi_byFernTec_adSwapper_local_v0x1x211_widgetSettingsSupport\ // load_widget_instance_settings( // $widget_instance_obj , // $widget_settings_dataset_slug , // &$all_application_dataset_definitions = NULL , // &$loaded_datasets = NULL , // &$core_plugapp_dirs = NULL , // &$app_handle = NULL // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // Returns this widget instance's currently saved settings (in a PHP // associative array). If the widget instances has NO settings (yet), // returns an empty array. // // Set $loaded_datasets to NULL if the (ARRAY STORAGE) datasets haven't // been loaded yet... // // $app_handle should be (eg):- // "teaser-maker" // "ad-swapper" // ... // // (and is only required if $loaded_datasets = NULL). // // RETURNS // On SUCCESS // ARRAY $widget_instance_settings // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $all_application_dataset_definitions = NULL ; $loaded_datasets = NULL ; $core_plugapp_dirs = NULL ; $app_handle = 'ad-swapper' ; // ------------------------------------------------------------------------- $widget_instance_settings = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_widgetSettingsSupport\load_widget_instance_settings( $that , $widget_settings_dataset_slug , $all_application_dataset_definitions , $loaded_datasets , $core_plugapp_dirs , $app_handle ) ; // ------------------------------------------------------------------------- if ( is_string( $widget_instance_settings ) ) { return nl2br( $widget_instance_settings ) ; } //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $widget_instance_settings ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $loaded_datasets = Array( // // [ad_swapper_ad_slots] => Array( // [title] => Ad Slots // [records] => Array( // [0] => Array( // [created_server_datetime_utc] => 1441072773 // [last_modified_server_datetime_utc] => 1441072773 // [key] => 68269847-ef98-4a79-b820-1767f4da0375-1441072773-509128-4787 // [local_key] => 8764154d5752463839c8060e84774dd91e5c607191a010eb8d6d3cffd728cc50 // [name] => fixed-height-banner // [title] => Fixed-Height Banner // [description] => // [type] => fixed-height-banner // [fixed_height_banner_outer_width_px] => 800 // [fixed_height_banner_outer_height_px] => 100 // [fixed_height_banner_border_top_px] => // [fixed_height_banner_border_bottom_px] => // [fixed_height_banner_border_left_px] => // [fixed_height_banner_border_right_px] => // [fixed_height_banner_border_colour_top] => // [fixed_height_banner_border_colour_bottom] => // [fixed_height_banner_border_colour_left] => // [fixed_height_banner_border_colour_right] => // [fixed_height_banner_fit_or_shrink] => // [fixed_height_banner_halign] => // [fixed_height_banner_valign] => // [fixed_height_banner_undercolour] => // [fixed_height_banner_extra_style] => // [sequence_number] => // [question_disabled] => // ) // // ... // // ) // // [key_field_slug] => key // // [record_indices_by_key] => Array( // [cf94d256-ece4-4b84-af71-6d562059ee4f-1420622748-483667-1405] => 0 // ... // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $loaded_datasets ) ; // ========================================================================= // Any Ad Slots ? // ========================================================================= if ( count( $loaded_datasets[ $ad_slots_dataset_slug ]['records'] ) < 1 ) { return <<

Oops; no "Ad Slots" yet :(

To have this widget display Ad Swapper ads, please:-

  1. Run the Ad Swapper plugin (from the WordPress Admin Menu, left).
  2. Create an "Ad Slot" (that defines how the ads to be displayed by this widget should be displayed).
  3. Come back here and select that Ad Slot.

Until you've done this, this widget won't display anything (on this site's front-end).

EOT; } // ========================================================================= // Get the currently selected Ad Slot's key... // ========================================================================= $currently_selected_ad_slot_key = '' ; // --------------------------------------------------------------------------- if ( array_key_exists( 'ad_slot_key' , $widget_instance_settings ) && is_string( $widget_instance_settings['ad_slot_key'] ) && trim( $widget_instance_settings['ad_slot_key'] ) !== '' ) { // --------------------------------------------------------------------- require_once( $core_plugapp_dirs['dataset_manager_includes_dir'] . '/record-key-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\ // is_record_key( // $candidate_record_key // ) // - - - - - - - - - - - - - - - - - // Is the input string a record key like (eg):- // // 3f2504e0-4f89-11d3-9a0c-0305e82c3301-1400040711-0-1 // 3f2504e0-4f89-11d3-9a0c-0305e82c3301-1400040711-999977-2147483647 // etc // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // FALSE // --------------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\is_record_key( $widget_instance_settings['ad_slot_key'] ) && array_key_exists( $widget_instance_settings['ad_slot_key'] , $loaded_datasets[ $ad_slots_dataset_slug ]['record_indices_by_key'] ) ) { $currently_selected_ad_slot_key = $widget_instance_settings['ad_slot_key'] ; } // --------------------------------------------------------------------- } //ob_start() ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $currently_selected_ad_slot_key , '$currently_selected_ad_slot_key' ) ; //$pr .= ob_get_clean() ; // ========================================================================= // Create an Ad Slot selector using radio buttons... // ========================================================================= $out = '' ; // ------------------------------------------------------------------------- // $id = $that->get_field_id( 'ad_slot_key') ; // $name = $that->get_field_name( 'ad_slot_key' ) ; $name = 'ad_slot_key' ; // ------------------------------------------------------------------------- $td_style_title = << $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'question_disabled' , $this_record ) && $this_record['question_disabled'] === TRUE ) { continue ; } // --------------------------------------------------------------------- if ( $this_record[ $ad_slots_key_field_slug ] === $currently_selected_ad_slot_key ) { $checked = 'checked="checked"' ; } else { $checked = '' ; } // --------------------------------------------------------------------- // $width_nominal = number_format( trim( $this_record['width_nominal'] ) ) ; // --------------------------------------------------------------------- // $height_nominal = number_format( trim( $this_record['height_nominal'] ) ) ; // --------------------------------------------------------------------- // id="{$id}" // {$width_nominal}w x {$height_nominal}h $out .= << {$this_record['title']} EOT; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( $currently_selected_ad_slot_key === '' ) { $checked = 'checked="checked"' ; } else { $checked = '' ; } // ------------------------------------------------------------------------- // id="{$id}" $out = <<

Please select the Ad Slot (to display this widget's ads with)...

{$out}
None (no ads will be shown)

You don't setup this ad slot here.  Setup this ad slot from the Ad Swapper (Local) plugin's Maintain This Site's Ad Slots option, instead.

EOT; // ========================================================================= // SUCCESS! // ========================================================================= return $out ; // ========================================================================= // That's that! // ========================================================================= } // ============================================================================= // That's that! // =============================================================================