1 ) ; return TRUE ; } // ------------------------------------------------------------------------- if ( ! is_array( $GLOBALS[ $number_ads_list_reloads_this_page_varname ] ) ) { $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; $ln = __LINE__ - 4 ; $msg = << 2 ) ; return TRUE ; } // ------------------------------------------------------------------------- if ( ! is_array( $GLOBALS[ $iteration_number_this_page_varname ] ) ) { $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; $ln = __LINE__ - 4 ; $msg = << "xxx" , // 'plugins_includes_dir' => "xxx" , // 'plugins_app_defs_dir' => "xxx" , // 'dataset_manager_includes_dir' => "xxx" , // (1) // 'apps_dot_app_dir' => "xxx" , // (2) // 'apps_plugin_stuff_dir' => "xxx" // (3) // 'custom_pages_dir' => "xxx" // (4) // ) // // (1) This is where most of the "Dataset Manager" includes files // are stored. // // (2) If $app_handle === NULL, the returned 'apps_dot_app_dir' // is NULL too. // // (3) If $app_handle === NULL, the returned 'apps_plugin_stuff_dir' // is NULL too. // // (4) If $app_handle === NULL, the returned 'custom_pages_dir' // is NULL too. // // --- // // $path_in_plugin should be a file, directory or link path in the // plugin (or "app") from which this function is called. Typically, // one uses __FILE__ for this purpose. Eg:- // // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI\get_single_app_defs_root_dir( __FILE__ ) ; // // --- // // $app_handle should be either:- // // o A single "app slug" - eg; "research-assistant" - as a // STRING. For which the returned dirspec might be (eg):- // // /home/joe/.../plugins/some-plugin/app-defs/research-assistant.app // // Or:- // // o An array of (nested) app slugs. Eg:- // // array( // 'some-app' , // 'child-app' , // 'grandchild-app' // [...] // ) // // For which the returned dirspec might be (eg):- // // /home/joe/.../plugins/some-plugin/app-defs/some-app.app/child-app.app/grandchild-app.app // // Exits with an error message if the directory can't be returned (eg; // doesn't exist). // // NOTE! // ----- // These "apps" and "datasets" (etc) are typically defined in a directory // tree structure like (eg):- // // /plugins/this-plugin/ // +-- app-defs/ // | +-- some-app.app/ // | | +-- child-app.app/ // | | +-- grandchild-app.app // | | +-- etc... // | +-- another-app.app/ // | +-- ... // +-- includes/ // +-- js/ // +-- admin/ // +-- remote/ // +-- ...etc... // +-- this-plugin.php // +-- ...etc... // // ------------------------------------------------------------------------- $path_in_plugin = __FILE__ ; $app_handle = 'ad-swapper' ; // --------------------------------------------------------------------- $GLOBALS[ $core_plugapp_dirs_varname ] = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI\get_core_plugapp_dirs( $path_in_plugin , $app_handle ) ; // --------------------------------------------------------------------- } // --------------------------------------------------------------------- return $GLOBALS[ $core_plugapp_dirs_varname ] ; // --------------------------------------------------------------------- } // ============================================================================= // get_loaded_datasets_4_ad_displayer() // ============================================================================= function get_loaded_datasets_4_ad_displayer() { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_adDisplayer\ // get_loaded_datasets_4_ad_displayer() // - - - - - - - - - - - - - - - - - - // Returns the loaded datasets, for the ad displayer. // // NOTE! The ad displayer routines are called from within WordPress // (Ad Swapper "ad slot") widgets. And thus, know nothing of // the:- // $loaded_datasets // // that may have been loaded by other code in the Ad Swapper // plugin. // // To prevent multiple reloads of these datasets, we cache the ad // displayer's version in $GLOBALS. // // RETURNS // ARRAY $loaded_datasets // // "dies()" on error // ------------------------------------------------------------------------- $core_plugapp_dirs = get_core_plugapp_dirs_4_ad_displayer() ; // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['apps_plugin_stuff_dir'] . '/includes/datasets-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_datasetSupport\ // get_ad_swapper_dataset_records( // $core_plugapp_dirs , // $question_front_end , // ) // - - - - - - - - - - - - - - - // Returns the CACHED Ad Swapper dataset records. // // RETURNS:- // // On FAILURE // $error_message STRING // // On SUCCESS // array( // $app_defs_directory_tree , // $applications_dataset_and_view_definitions_etc , // $all_application_dataset_definitions , // $loaded_datasets // ) // // Where:- // // $loaded_datasets = Array( // // [ad_swapper_impressions] => Array( // [title] => Impressions // [records] => Array() // [key_field_slug] => key // [record_indices_by_key] => Array() // ) // // [ad_swapper_settings] => Array( // [title] => Settings // [records] => Array( // [0] => Array( // [created_server_datetime_utc] => 1416388978 // [last_modified_server_datetime_utc] => 1416388978 // [key] => c885e81e-4af9-40bd-a485-34c9d835d9e5-1416388978-679287-1131 // [api_url_override] => http://localhost/plugdev/wp-content/plugins/plugin-plant/app-defs/ad-swapper-central.app/plugin.stuff/api/api-call-handler.php // ) // ) // [key_field_slug] => key // [record_indices_by_key] => Array( // [c885e81e-4af9-40bd-a485-34c9d835d9e5-1416388978-679287-1131] => 0 // ) // ) // // [ad_swapper_site_profile] => Array( // [title] => Site Profile // [records] => Array( // [0] => Array( // [created_server_datetime_utc] => 1416718948 // [last_modified_server_datetime_utc] => 1416718948 // [key] => 9475e467-59b6-4f6d-9f32-5413e2b07c4e-1416718948-108185-1163 // [site_owners_ad_swapper_user_sid] => z4v2-mkcx-wh79-yg3n // [site_url] => http://www.example.com // [site_title] => The Site // [site_description] => // [ads_wanted_description] => // [sites_wanted_description] => // [categories_available] => // [categories_wanted] => // ) // ) // [key_field_slug] => key // [record_indices_by_key] => Array( // [9475e467-59b6-4f6d-9f32-5413e2b07c4e-1416718948-108185-1163] => 0 // ) // ) // // ) // // ------------------------------------------------------------------------- $question_front_end = FALSE ; // ------------------------------------------------------------------------- $dataset_records = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_datasetSupport\get_ad_swapper_dataset_records( $core_plugapp_dirs , $question_front_end ) ; // ------------------------------------------------------------------------- if ( is_string( $dataset_records ) ) { die( nl2br( $msg ) ) ; } // ------------------------------------------------------------------------- list( $app_defs_directory_tree , $applications_dataset_and_view_definitions_etc , $all_application_dataset_definitions , $loaded_datasets ) = $dataset_records ; // ------------------------------------------------------------------------- return $loaded_datasets ; // ------------------------------------------------------------------------- } // ============================================================================= // is_start_of_page_for() // ============================================================================= function is_start_of_page_for( $id_string ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_adDisplayer\ // is_start_of_page_for( // $id_string // ) // - - - - - - - - - - - // This function returns TRUE the first time it's called (with a given // $id_string). The second and subsequent calls (with the same // $id_string), return FALSE. // // The $id_string:- // // o Must be a valid PHP variable name, and; // // o When appended to:- // "greatKiwi_byFernTec_adSwapper_local_v0x1x211_adDisplayer_" // // must generate a UNIQUE variable name that WON'T conflict with // any other GLOBAL variable name that might be generated (by // this version of the plugin "is_start_page_for()" is called // from). // // RETURNS // TRUE or FALSE // // dies() on error. // ------------------------------------------------------------------------- if ( ! is_string( $id_string ) || trim( $id_string ) === '' ) { $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; $ln = __LINE__ - 6 ; $msg = <<prepare before the INSERT statement but not the option value, // this value should always be properly sanitized. // // This function may be used in place of add_option, although it is not as // flexible. update_option will check to see if the option already exists. // If it does not, it will be added with add_option('option_name', // 'option_value'). Unless you need to specify the optional arguments of // add_option(), update_option() is a useful catch-all for both adding and // updating options. // // $option // (string) (required) Name of the option to update. Must not // exceed 64 characters. A list of valid default options to update // can be found at the Option Reference. // Default: None // // $new_value // (mixed) (required) The NEW value for this option name. This // value can be an integer, string, array, or object. // Default: None // // $autoload // (mixed) (optional) Whether to load the option when WordPress // starts up. For existing options `$autoload` can only be updated // using `update_option()` if `$value` is also changed. Accepts // 'yes' or true to enable, 'no' or false to disable. For // non-existent options, the default value is 'yes'. // Default: null // // RETURN VALUE // (boolean) True if option value has changed, false if not or if // update failed. // ------------------------------------------------------------------------- update_option( get_option_name_4_update_LOCAL_site_run_since_ads_list_last_reloaded() , $value ) ; // ------------------------------------------------------------------------- return TRUE ; */ // ------------------------------------------------------------------------- } // ============================================================================= // get_boolean_option() // ============================================================================= function get_boolean_option( $option_name , $die_if_not_exist = FALSE ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_adDisplayer\ // get_boolean_option( // $option_name , // $die_if_not_exist = FALSE // ) // - - - - - - - - - - - - - - - - - // Retrieves a PHP BOOLEAN value (TRUE or FALSE), from the WordPress // options database. // // NOTE! // ===== // The BOOLEAN value MUST have been saved with "update_option_properly()". // // RETURNS // If $die_if_not_exist = TRUE // TRUE or FALSE // dies() if option doesn't exist // If $die_if_not_exist = FALSE // TRUE or FALSE // NULL if option doesn't exist // // die()s on other error // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // In conjunction with "update_option_properly()", solves the bugs that // "update_option()":- // // 1. Can only save:- // integer, string, array, or object // // And; // // 2. Converts integers to string. // ------------------------------------------------------------------------- $safe_option_name = htmlentities( (string) $option_name ) ; // ------------------------------------------------------------------------- if ( ! is_string( $option_name ) || trim( $option_name ) === '' ) { $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; $ln = __LINE__ - 6 ; $msg = <<' , $option_name , ' = ' , $existing_value ; var_dump( $existing_value ) ; // ------------------------------------------------------------------------- if ( $existing_value !== $default ) { // Option exists // --------------------------------------------------------------------- // Convert INTs back from STRINGS (for the "already set" comparison // that follows)... // --------------------------------------------------------------------- if ( is_int( $new_value ) && is_string( $existing_value ) && ctype_digit( $existing_value ) ) { $existing_value = (int) $existing_value ; } // --------------------------------------------------------------------- // No update required if $new_value is already set. // --------------------------------------------------------------------- if ( $new_value === TRUE ) { if ( $existing_value === '1' ) { return TRUE ; } } elseif ( $new_value === FALSE ) { if ( $existing_value === '0' ) { return TRUE ; } } else { if ( $existing_value === $new_value ) { return TRUE ; } } // --------------------------------------------------------------------- } // -------------------------------------------------------------------------- // BOOLEAN support... // -------------------------------------------------------------------------- if ( $new_value === TRUE ) { $new_value = '1' ; } elseif ( $new_value === FALSE ) { $new_value = '0' ; } // ------------------------------------------------------------------------- // update_option( $option , $new_value , $autoload ) // - - - - - - - - - - - - - - - - - - - - - - - - - // Use the function update_option() to update a named option/value pair to // the options database table. The $option (option name) value is escaped // with $wpdb->prepare before the INSERT statement but not the option value, // this value should always be properly sanitized. // // This function may be used in place of add_option, although it is not as // flexible. update_option will check to see if the option already exists. // If it does not, it will be added with add_option('option_name', // 'option_value'). Unless you need to specify the optional arguments of // add_option(), update_option() is a useful catch-all for both adding and // updating options. // // $option // (string) (required) Name of the option to update. Must not // exceed 64 characters. A list of valid default options to update // can be found at the Option Reference. // Default: None // // $new_value // (mixed) (required) The NEW value for this option name. This // value can be an integer, string, array, or object. // Default: None // // $autoload // (mixed) (optional) Whether to load the option when WordPress // starts up. For existing options `$autoload` can only be updated // using `update_option()` if `$value` is also changed. Accepts // 'yes' or true to enable, 'no' or false to disable. For // non-existent options, the default value is 'yes'. // Default: null // // RETURN VALUE // (boolean) True if option value has changed, false if not or if // update failed. // ------------------------------------------------------------------------- $result = update_option( $option_name , $new_value , $autoload ) ; // ------------------------------------------------------------------------- if ( $result !== TRUE ) { $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; $ln = __LINE__ - 4 ; $safe_option_name = htmlentities( $option_name ) ; $msg = <<