Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/custom-t.../inc
File: CtfFeed.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Class CtfFeed
[2] Fix | Delete
*
[3] Fix | Delete
* Creates the settings for the feed and outputs the html
[4] Fix | Delete
*/
[5] Fix | Delete
namespace TwitterFeed;
[6] Fix | Delete
[7] Fix | Delete
use TwitterFeed\CTF_Parse;
[8] Fix | Delete
use TwitterFeed\CtfCache;
[9] Fix | Delete
use TwitterFeed\CTF_Feed;
[10] Fix | Delete
use TwitterFeed\CTF_Settings;
[11] Fix | Delete
use TwitterFeed\V2\CtfOauthConnect;
[12] Fix | Delete
use TwitterFeed\CTF_Feed_Locator;
[13] Fix | Delete
use TwitterFeed\CTF_GDPR_Integrations;
[14] Fix | Delete
use TwitterFeed\Builder\CTF_Feed_Builder;
[15] Fix | Delete
use TwitterFeed\SmashTwitter\ErrorReport;
[16] Fix | Delete
use TwitterFeed\SmashTwitter\SettingsFilter;
[17] Fix | Delete
use TwitterFeed\SmashTwitter\TweetFilterer;
[18] Fix | Delete
use TwitterFeed\SmashTwitter\TweetSetModifier;
[19] Fix | Delete
[20] Fix | Delete
// Don't load directly
[21] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[22] Fix | Delete
die( '-1' );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
class CtfFeed
[26] Fix | Delete
{
[27] Fix | Delete
/**
[28] Fix | Delete
* @var array
[29] Fix | Delete
*/
[30] Fix | Delete
public $errors = array();
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* @var array
[34] Fix | Delete
*/
[35] Fix | Delete
protected $atts;
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* @var string
[39] Fix | Delete
*/
[40] Fix | Delete
protected $last_id_data;
[41] Fix | Delete
[42] Fix | Delete
private $num_needed_input;
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* @var mixed|void
[46] Fix | Delete
*/
[47] Fix | Delete
protected $db_options;
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* @var array
[51] Fix | Delete
*/
[52] Fix | Delete
public $feed_options = array();
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* @var mixed|void
[56] Fix | Delete
*/
[57] Fix | Delete
public $missing_credentials;
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* @var string
[61] Fix | Delete
*/
[62] Fix | Delete
public $transient_name;
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* @var bool
[66] Fix | Delete
*/
[67] Fix | Delete
protected $transient_data = false;
[68] Fix | Delete
[69] Fix | Delete
protected $raw_shortcode_atts;
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* @var int
[73] Fix | Delete
*/
[74] Fix | Delete
private $num_tweets_needed;
[75] Fix | Delete
[76] Fix | Delete
private $check_for_duplicates = false;
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* @var array
[80] Fix | Delete
*/
[81] Fix | Delete
public $tweet_set;
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* @var object
[85] Fix | Delete
*/
[86] Fix | Delete
public $api_obj;
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* @var string
[90] Fix | Delete
*/
[91] Fix | Delete
public $feed_html;
[92] Fix | Delete
[93] Fix | Delete
private $persistent_index;
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* @var string
[97] Fix | Delete
*/
[98] Fix | Delete
public $feed_id;
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* @var CtfCache
[102] Fix | Delete
*/
[103] Fix | Delete
public $cache;
[104] Fix | Delete
[105] Fix | Delete
/**
[106] Fix | Delete
* @var boolean
[107] Fix | Delete
*/
[108] Fix | Delete
public $is_legacy;
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* @var boolean
[112] Fix | Delete
*/
[113] Fix | Delete
public $unique_legacy_id;
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* @var SettingsFilter
[117] Fix | Delete
*/
[118] Fix | Delete
public $settings_filter;
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* @var ErrorReport
[122] Fix | Delete
*/
[123] Fix | Delete
public $error_report;
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* retrieves and sets options that apply to the feed
[127] Fix | Delete
*
[128] Fix | Delete
* @param array $atts data from the shortcode
[129] Fix | Delete
* @param string $last_id_data the last visible tweet on the feed, empty string if first set
[130] Fix | Delete
* @param int $num_needed_input this number represents the number left to retrieve after the first set
[131] Fix | Delete
*/
[132] Fix | Delete
public function __construct($atts, $last_id_data, $num_needed_input, $preview_settings = false) {
[133] Fix | Delete
$this->settings_filter = new SettingsFilter();
[134] Fix | Delete
$this->error_report = new ErrorReport();
[135] Fix | Delete
[136] Fix | Delete
//$this->atts = $atts;
[137] Fix | Delete
$this->atts = CTF_Settings::filter_atts_for_legacy($atts);
[138] Fix | Delete
$this->raw_shortcode_atts = CTF_Settings::filter_atts_for_legacy($atts);
[139] Fix | Delete
if( isset($this->atts['feed']) ){
[140] Fix | Delete
$atts['feed'] = $this->atts['feed'];
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
$this->last_id_data = $last_id_data;
[144] Fix | Delete
$this->num_needed_input = $num_needed_input;
[145] Fix | Delete
$this->db_options = get_option( 'ctf_options', array() );
[146] Fix | Delete
$this->is_legacy = false;
[147] Fix | Delete
if ( ! empty( $atts['feed'] ) && $atts['feed'] !== 'legacy' ) {
[148] Fix | Delete
$this->feed_id = $this->atts['feed'];
[149] Fix | Delete
$this->feed_options = CTF_Settings::get_settings_by_feed_id( $atts['feed'], $preview_settings );
[150] Fix | Delete
if($this->feed_options == false){
[151] Fix | Delete
$this->feed_options['feederror'] = true;
[152] Fix | Delete
}else{
[153] Fix | Delete
$this->feed_options['feed'] = $this->feed_id;
[154] Fix | Delete
$this->atts = $this->feed_options;
[155] Fix | Delete
add_action( 'wp_footer', [ $this, 'get_feed_style' ] );
[156] Fix | Delete
}
[157] Fix | Delete
}else{
[158] Fix | Delete
$ctf_statuses = get_option( 'ctf_statuses', array() );
[159] Fix | Delete
if ( ! empty( $ctf_statuses['support_legacy_shortcode'] ) ) {
[160] Fix | Delete
if($preview_settings !== false && is_array($preview_settings)){
[161] Fix | Delete
$this->feed_options = wp_parse_args( $this->atts, $preview_settings );
[162] Fix | Delete
}else{
[163] Fix | Delete
$legacy_settings_option = self::get_legacy_feed_settings();
[164] Fix | Delete
if ( empty( $legacy_settings_option ) ) {
[165] Fix | Delete
$this->feed_options = CTF_Settings::legacy_shortcode_atts( $this->atts, $this->db_options );
[166] Fix | Delete
} else {
[167] Fix | Delete
$this->feed_options = wp_parse_args( $this->atts, $legacy_settings_option );
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
$this->atts = wp_parse_args( $this->atts, \TwitterFeed\Builder\CTF_Feed_Saver::settings_defaults() );
[171] Fix | Delete
$this->feed_options = wp_parse_args( $this->feed_options, $this->atts );
[172] Fix | Delete
$this->feed_options['persistentcache'] = $this->atts['persistentcache'];
[173] Fix | Delete
[174] Fix | Delete
add_action( 'wp_footer', [ $this, 'get_feed_style' ] );
[175] Fix | Delete
}
[176] Fix | Delete
$this->unique_legacy_id = rand( 1, time() );
[177] Fix | Delete
$this->is_legacy = true;
[178] Fix | Delete
[179] Fix | Delete
}
[180] Fix | Delete
if ( ! empty( $this->feed_options ) ) {
[181] Fix | Delete
$this->feed_options['customizer'] = isset($atts['customizer']) && $atts['customizer'] == true ? true : false;
[182] Fix | Delete
}
[183] Fix | Delete
if ( ! empty( $atts['feed'] ) ) {
[184] Fix | Delete
$this->feed_options['feed'] = $atts['feed'];
[185] Fix | Delete
}
[186] Fix | Delete
$this->feed_options['selfreplies'] = false;
[187] Fix | Delete
$this->feed_options['includereplies'] = false;
[188] Fix | Delete
$this->feed_options['is_legacy'] = $this->is_legacy;
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
/**
[192] Fix | Delete
* creates and returns all of the data needed to generate the output for the feed
[193] Fix | Delete
*
[194] Fix | Delete
* @param array $atts data from the shortcode
[195] Fix | Delete
* @param string $last_id_data the last visible tweet on the feed, empty string if first set
[196] Fix | Delete
* @param int $num_needed_input this number represents the number left to retrieve after the first set
[197] Fix | Delete
* @return CtfFeed the complete object for the feed
[198] Fix | Delete
*/
[199] Fix | Delete
public static function init( $atts, $last_id_data = '', $num_needed_input = 0, $ids_to_remove = array(), $persistent_index = 1, $preview_settings = false ){
[200] Fix | Delete
if ( empty( $atts['feed'] ) ) {
[201] Fix | Delete
$ctf_statuses = get_option( 'ctf_statuses', array() );
[202] Fix | Delete
if ( empty( $ctf_statuses['support_legacy_shortcode'] ) ) {
[203] Fix | Delete
if ( empty( $atts ) ) {
[204] Fix | Delete
$atts = array();
[205] Fix | Delete
}
[206] Fix | Delete
$atts['feed'] = 1;
[207] Fix | Delete
}
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
$feed = new CtfFeed( $atts, $last_id_data, $num_needed_input, $preview_settings );
[211] Fix | Delete
$feed->setFeedOptions();
[212] Fix | Delete
[213] Fix | Delete
$feed->setCacheTypeOption();
[214] Fix | Delete
[215] Fix | Delete
if (CTF_DOING_SMASH_TWITTER || $feed->feed_options['persistentcache']) {
[216] Fix | Delete
$feed->persistent_index = $persistent_index;
[217] Fix | Delete
}
[218] Fix | Delete
$feed->setTweetSet();
[219] Fix | Delete
return $feed;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* creates all of the feed options with shortcode settings having the highest priority
[224] Fix | Delete
*/
[225] Fix | Delete
public function setFeedOptions(){
[226] Fix | Delete
$this->feed_options['num'] = isset($this->feed_options['num']) && !empty($this->feed_options['num']) ? $this->feed_options['num'] : 1;
[227] Fix | Delete
$this->setFeedTypeAndTermOptions();
[228] Fix | Delete
$this->setAccessTokenAndSecretOptions();
[229] Fix | Delete
$this->setConsumerKeyAndSecretOptions();
[230] Fix | Delete
$db_only = array(
[231] Fix | Delete
'request_method'
[232] Fix | Delete
);
[233] Fix | Delete
$this->setDatabaseOnlyOptions( $db_only );
[234] Fix | Delete
$this->setCacheTimeOptions();
[235] Fix | Delete
$this->setIncludeExcludeOptions();
[236] Fix | Delete
[237] Fix | Delete
if ( CTF_GDPR_Integrations::doing_gdpr( $this->feed_options ) ) {
[238] Fix | Delete
CTF_GDPR_Integrations::init();
[239] Fix | Delete
}
[240] Fix | Delete
$this->feed_options['usertimeline_includeretweets'] = true;
[241] Fix | Delete
[242] Fix | Delete
if ( CTF_DOING_SMASH_TWITTER ) {
[243] Fix | Delete
$this->settings_filter->set_settings( $this->feed_options );
[244] Fix | Delete
if ( empty( $this->feed_options['feed_types_and_terms'] ) ) {
[245] Fix | Delete
$this->feed_options['feed_types_and_terms'] = array();
[246] Fix | Delete
}
[247] Fix | Delete
$this->settings_filter->set_feed_type_and_terms( $this->feed_options['feed_types_and_terms'] );
[248] Fix | Delete
[249] Fix | Delete
$this->settings_filter->filter_feed_type_and_terms();
[250] Fix | Delete
[251] Fix | Delete
$this->feed_options = $this->settings_filter->get_settings();
[252] Fix | Delete
$this->feed_options['feed_types_and_terms'] = $this->settings_filter->get_feed_type_and_terms();
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* uses the feed options to set the the tweets in the feed by using
[258] Fix | Delete
* an existing set in a cache or by retrieving them from Twitter
[259] Fix | Delete
*/
[260] Fix | Delete
protected function setTweetSet(){
[261] Fix | Delete
$this->setTransientName();
[262] Fix | Delete
if ( ! empty( $this->feed_options['feed'] ) ) {
[263] Fix | Delete
$feed_id = $this->feed_options['feed'];
[264] Fix | Delete
} else {
[265] Fix | Delete
$feed_id = 'legacy';
[266] Fix | Delete
}
[267] Fix | Delete
if ( ! empty( $this->last_id_data ) ) {
[268] Fix | Delete
$page = $this->last_id_data;
[269] Fix | Delete
} else {
[270] Fix | Delete
$page = '';
[271] Fix | Delete
}
[272] Fix | Delete
$this->cache = new CtfCache( $feed_id, $this->feed_options['cache_time'], $page );
[273] Fix | Delete
if (! empty($this->raw_shortcode_atts['doingcronupdate'])) {
[274] Fix | Delete
$this->maybeSetTweetsFromTwitter();
[275] Fix | Delete
return;
[276] Fix | Delete
}
[277] Fix | Delete
$success = $this->maybeSetTweetsFromCache();
[278] Fix | Delete
[279] Fix | Delete
$is_persistent = $this->feed_options['persistentcache'] && ($this->feed_options['type'] == 'search' || $this->feed_options['type'] == 'hashtag');
[280] Fix | Delete
if ( ! $success && ! $is_persistent) {
[281] Fix | Delete
$this->maybeSetTweetsFromTwitter();
[282] Fix | Delete
} elseif ( ! $success && $is_persistent ) {
[283] Fix | Delete
$this->errors['error_message'] = 'No Tweets returned';
[284] Fix | Delete
if (empty($this->api_obj)) {
[285] Fix | Delete
$this->api_obj = new \stdClass();
[286] Fix | Delete
}
[287] Fix | Delete
$this
[288] Fix | Delete
->api_obj->api_error_no = '';
[289] Fix | Delete
$this
[290] Fix | Delete
->api_obj->api_error_message = 'No Tweets returned';
[291] Fix | Delete
$this->tweet_set = false;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$this->num_tweets_needed = $this->numTweetsNeeded();
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
/**
[298] Fix | Delete
* the access token and secret must be set in order for the feed to work
[299] Fix | Delete
* this function processes the user input and sets a flag if none are entered
[300] Fix | Delete
*/
[301] Fix | Delete
private function setAccessTokenAndSecretOptions()
[302] Fix | Delete
{
[303] Fix | Delete
if ( CTF_DOING_SMASH_TWITTER ) {
[304] Fix | Delete
$this->feed_options['access_token'] = 'missing';
[305] Fix | Delete
$this->feed_options['access_token_secret'] = 'missing';
[306] Fix | Delete
[307] Fix | Delete
} else {
[308] Fix | Delete
$this->feed_options['access_token'] = isset( $this->db_options['access_token'] ) && strlen( $this->db_options['access_token'] ) > 30 ? $this->db_options['access_token'] : 'missing';
[309] Fix | Delete
$this->feed_options['access_token_secret'] = isset( $this->db_options['access_token_secret'] ) && strlen( $this->db_options['access_token_secret'] ) > 30 ? $this->db_options['access_token_secret'] : 'missing';
[310] Fix | Delete
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
// verify that access token and secret have been entered
[314] Fix | Delete
$this->setMissingCredentials();
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
/**
[318] Fix | Delete
* generates the flag if there are missing access tokens
[319] Fix | Delete
*/
[320] Fix | Delete
private function setMissingCredentials() {
[321] Fix | Delete
if ( $this->feed_options['access_token'] == 'missing' || $this->feed_options['access_token_secret'] == 'missing' ) {
[322] Fix | Delete
$this->missing_credentials = true;
[323] Fix | Delete
} else {
[324] Fix | Delete
$this->missing_credentials = false;
[325] Fix | Delete
}
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* processes the consumer key and secret options
[330] Fix | Delete
*/
[331] Fix | Delete
protected function setConsumerKeyAndSecretOptions(){
[332] Fix | Delete
if (! empty( $this->db_options['consumer_key'] ) && ! empty($this->db_options['consumer_secret'] )) {
[333] Fix | Delete
$this->feed_options['consumer_key'] = isset($this->db_options['consumer_key']) && strlen($this->db_options['consumer_key']) > 15 ? $this->db_options['consumer_key'] : 'FPYSYWIdyUIQ76Yz5hdYo5r7y';
[334] Fix | Delete
$this->feed_options['consumer_secret'] = isset($this->db_options['consumer_secret']) && strlen($this->db_options['consumer_secret']) > 30 ? $this->db_options['consumer_secret'] : 'GqPj9BPgJXjRKIGXCULJljocGPC62wN2eeMSnmZpVelWreFk9z';
[335] Fix | Delete
} else {
[336] Fix | Delete
$this->feed_options['consumer_key'] = 'FPYSYWIdyUIQ76Yz5hdYo5r7y';
[337] Fix | Delete
$this->feed_options['consumer_secret'] = 'GqPj9BPgJXjRKIGXCULJljocGPC62wN2eeMSnmZpVelWreFk9z';
[338] Fix | Delete
}
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
/**
[342] Fix | Delete
* determines what value to use and saves it for the appropriate key in the feed_options array
[343] Fix | Delete
*
[344] Fix | Delete
* @param $options mixed the key or array of keys to be set
[345] Fix | Delete
* @param $options_page string options page this setting is set on
[346] Fix | Delete
* @param string $default default value to use if there is no user input
[347] Fix | Delete
*/
[348] Fix | Delete
public function setDatabaseOnlyOptions( $options, $default = '' )
[349] Fix | Delete
{
[350] Fix | Delete
if ( is_array( $options ) ) {
[351] Fix | Delete
foreach ( $options as $option ) {
[352] Fix | Delete
$this->feed_options[$option] = isset( $this->db_options[$option] ) && ! empty( $this->db_options[$option] ) ? $this->db_options[$option] : $default;
[353] Fix | Delete
}
[354] Fix | Delete
} else {
[355] Fix | Delete
$this->feed_options[$options] = isset( $this->db_options[$options] ) && ! empty( $this->db_options[$options] ) ? $this->db_options[$options] : $default;
[356] Fix | Delete
}
[357] Fix | Delete
}
[358] Fix | Delete
[359] Fix | Delete
/**
[360] Fix | Delete
* determines what value to use and saves it for the appropriate key in the feed_options array
[361] Fix | Delete
*
[362] Fix | Delete
* @param $options mixed the key or array of keys to be set
[363] Fix | Delete
* @param $options_page string options page this setting is set on
[364] Fix | Delete
* @param string $default default value to use if there is no user input
[365] Fix | Delete
*/
[366] Fix | Delete
public function setStandardTextOptions( $options, $default = '' )
[367] Fix | Delete
{
[368] Fix | Delete
if ( is_array( $options ) ) {
[369] Fix | Delete
foreach ( $options as $option ) {
[370] Fix | Delete
$this->feed_options[$option] = isset( $this->atts[$option] ) ? esc_attr( __( $this->atts[$option], 'custom-twitter-feeds' ) ) : ( isset( $this->db_options[$option] ) ? esc_attr( $this->db_options[$option] ) : $default );
[371] Fix | Delete
}
[372] Fix | Delete
} else {
[373] Fix | Delete
$this->feed_options[$options] = isset( $this->atts[$options] ) ? esc_attr( __( $this->atts[$options], 'custom-twitter-feeds' ) ) : ( isset( $this->db_options[$options] ) ? esc_attr( $this->db_options[$options] ) : $default );
[374] Fix | Delete
}
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
/**
[378] Fix | Delete
* creates the appropriate style attribute string for the text size setting
[379] Fix | Delete
*
[380] Fix | Delete
* @param $value mixed pixel size or other that the user has selected
[381] Fix | Delete
* @return string string for the style attribute
[382] Fix | Delete
*/
[383] Fix | Delete
public static function processTextSizeStyle( $value )
[384] Fix | Delete
{
[385] Fix | Delete
if ( $value == '' ) {
[386] Fix | Delete
return '';
[387] Fix | Delete
}
[388] Fix | Delete
$processed_value = $value == 'inherit' ? '' : 'font-size: ' . $value . 'px;';
[389] Fix | Delete
[390] Fix | Delete
return $processed_value;
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
/**
[394] Fix | Delete
* determines what value to use and saves it for the appropriate key in the feed_options array
[395] Fix | Delete
*
[396] Fix | Delete
* @param $options mixed the key or array of keys to be set
[397] Fix | Delete
* @param string $default default value to use if there is no user input
[398] Fix | Delete
*/
[399] Fix | Delete
public function setTextSizeOptions( $options, $default = '' )
[400] Fix | Delete
{
[401] Fix | Delete
if ( is_array( $options ) ) {
[402] Fix | Delete
foreach ( $options as $option ) {
[403] Fix | Delete
$this->feed_options[$option] = isset( $this->atts[$option] ) ? $this->processTextSizeStyle( esc_attr( $this->atts[$option] ) ) : ( isset( $this->db_options[$option] ) ? $this->processTextSizeStyle( esc_attr( $this->db_options[$option] ) ) : $default );
[404] Fix | Delete
}
[405] Fix | Delete
} else {
[406] Fix | Delete
$this->feed_options[$options] = isset( $this->atts[$options] ) ? $this->processTextSizeStyle( esc_attr( $this->atts[$options] ) ) : ( isset( $this->db_options[$options] ) ? $this->processTextSizeStyle( esc_attr( $this->db_options[$options] ) ) : $default );
[407] Fix | Delete
}
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
/**
[411] Fix | Delete
* determines what value to use and saves it for the appropriate key in the feed_options array
[412] Fix | Delete
*
[413] Fix | Delete
* @param $options mixed the key or array of keys to be set
[414] Fix | Delete
* @param $property string name of the property to be set
[415] Fix | Delete
* @param string $default default value to use if there is no user input
[416] Fix | Delete
*/
[417] Fix | Delete
public function setStandardStyleProperty( $options, $property, $default = '' )
[418] Fix | Delete
{
[419] Fix | Delete
if ( is_array( $options ) ) {
[420] Fix | Delete
foreach ( $options as $option ) {
[421] Fix | Delete
$this->feed_options[$option] = isset( $this->atts[$option] ) && $this->atts[$option] != 'inherit' ? $property . ': ' . esc_attr( $this->atts[$option] ) . ';' : ( isset( $this->db_options[$option] ) && $this->db_options[$option] != '#' && $this->db_options[$option] != '' && $this->db_options[$option] != 'inherit' ? $property . ': ' . esc_attr( $this->db_options[$option] ) . ';' : $default );
[422] Fix | Delete
}
[423] Fix | Delete
} else {
[424] Fix | Delete
$this->feed_options[$options] = isset( $this->atts[$options] ) && $this->atts[$options] != 'inherit' ? $property . ': ' . esc_attr( $this->atts[$options] ) . ';' : ( isset( $this->db_options[$options] ) && $this->db_options[$options] != '#' && $this->db_options[$options] != '' && $this->db_options[$options] != 'inherit' ? $property . ': ' . esc_attr( $this->db_options[$options] ) . ';' : $default );
[425] Fix | Delete
}
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
/**
[429] Fix | Delete
* determines what value to use and saves it for the appropriate key in the feed_options array
[430] Fix | Delete
*
[431] Fix | Delete
* @param $options mixed the key or array of keys to be set
[432] Fix | Delete
* @param bool|true $default default value to use if there is no user input
[433] Fix | Delete
*/
[434] Fix | Delete
public function setStandardBoolOptions( $options, $default = true )
[435] Fix | Delete
{
[436] Fix | Delete
if ( is_array( $options ) ) {
[437] Fix | Delete
foreach ( $options as $option ) {
[438] Fix | Delete
$this->feed_options[$option] = isset( $this->atts[$option] ) ? ( $this->atts[$option] === 'true' ) : ( isset( $this->db_options[$option] ) ? (bool) $this->db_options[$option] : (bool) $default );
[439] Fix | Delete
}
[440] Fix | Delete
} else {
[441] Fix | Delete
$this->feed_options[$options] = isset( $this->atts[$options] ) ? esc_attr( $this->atts[$options] ) : ( isset( $this->db_options[$options] ) ? esc_attr( $this->db_options[$options] ) : $default );
[442] Fix | Delete
}
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
/**
[446] Fix | Delete
* sets the width and height of the feed based on user input
[447] Fix | Delete
*/
[448] Fix | Delete
public function setDimensionOptions(){
[449] Fix | Delete
$this->feed_options['width'] = isset( $this->atts['width'] ) ? 'width: '. esc_attr( $this->atts['width'] ) .';' : ( ( isset( $this->db_options['width'] ) && $this->db_options['width'] != '' ) ? 'width: '. esc_attr( $this->db_options['width'] ) . ( isset( $this->db_options['width_unit'] ) ? esc_attr( $this->db_options['width_unit'] ) : '%' ) . ';' : '' );
[450] Fix | Delete
$this->feed_options['height'] = isset( $this->atts['height'] ) ? 'height: '. esc_attr( $this->atts['height'] ) .';' : ( ( isset( $this->db_options['height'] ) && $this->db_options['height'] != '' ) ? 'height: '. esc_attr( $this->db_options['height'] ) . ( isset( $this->db_options['height_unit'] ) ? esc_attr( $this->db_options['height_unit'] ) : 'px' ) . ';' : '' );
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
/**
[454] Fix | Delete
* sets the cache time based on user input
[455] Fix | Delete
*/
[456] Fix | Delete
public function setCacheTimeOptions(){
[457] Fix | Delete
if ( ! empty( $this->raw_shortcode_atts ) && ! empty( $this->raw_shortcode_atts['doingcronupdate'] ) ) {
[458] Fix | Delete
$this->feed_options['cache_time'] = 60;
[459] Fix | Delete
return;
[460] Fix | Delete
}
[461] Fix | Delete
$user_cache = isset($this->db_options['cache_time']) ? ((int)$this->db_options['cache_time'] * (int)$this->db_options['cache_time_unit']) : HOUR_IN_SECONDS;
[462] Fix | Delete
$caching_type = ! empty( $this->db_options['ctf_caching_type'] ) ? $this->db_options['ctf_caching_type'] : 'page';
[463] Fix | Delete
if ( empty( $this->raw_shortcode_atts['feed'] ) || $caching_type === 'page' ) {
[464] Fix | Delete
$this->feed_options['cache_time'] = max($user_cache, 60);
[465] Fix | Delete
} else {
[466] Fix | Delete
$this->feed_options['cache_time'] = DAY_IN_SECONDS + HOUR_IN_SECONDS;
[467] Fix | Delete
}
[468] Fix | Delete
}
[469] Fix | Delete
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
* sets the number of tweets to retrieve
[473] Fix | Delete
*/
[474] Fix | Delete
public function setTweetsToRetrieve(){
[475] Fix | Delete
$min_tweets_to_retrieve = 10;
[476] Fix | Delete
[477] Fix | Delete
if ($this->num_needed_input < 1) {
[478] Fix | Delete
[479] Fix | Delete
if ($this->feed_options['num'] < 10) {
[480] Fix | Delete
$count = max(round((int)$this->feed_options['num'] * (float)$this->feed_options['multiplier'] * 1.6) , $min_tweets_to_retrieve);
[481] Fix | Delete
}
[482] Fix | Delete
elseif ($this->feed_options['num'] < 30) {
[483] Fix | Delete
$count = round((int)$this->feed_options['num'] * (float)$this->feed_options['multiplier'] * 1.2);
[484] Fix | Delete
}
[485] Fix | Delete
else {
[486] Fix | Delete
$count = round((int)$this->feed_options['num'] * (float)$this->feed_options['multiplier']);
[487] Fix | Delete
}
[488] Fix | Delete
}
[489] Fix | Delete
else {
[490] Fix | Delete
$count = max($this->num_needed_input, 50);
[491] Fix | Delete
$this->feed_options['num'] = $this->num_needed_input;
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
$this->feed_options['count'] = min($count, 200);
[495] Fix | Delete
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
/**
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function