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...
File: custom-twitter-feed.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
Plugin Name: Custom Twitter Feeds
[2] Fix | Delete
Plugin URI: https://smashballoon.com/custom-twitter-feeds
[3] Fix | Delete
Description: Customizable X Feeds, formerly known as Twitter feeds, for your website
[4] Fix | Delete
Version: 2.2.2
[5] Fix | Delete
Author: Smash Balloon
[6] Fix | Delete
Author URI: https://smashballoon.com/
[7] Fix | Delete
Text Domain: custom-twitter-feeds
[8] Fix | Delete
*/
[9] Fix | Delete
/*
[10] Fix | Delete
Copyright 2024 Smash Balloon LLC (email : hey@smashballoon.com)
[11] Fix | Delete
This program is free software; you can redistribute it and/or modify
[12] Fix | Delete
it under the terms of the GNU General Public License as published by
[13] Fix | Delete
the Free Software Foundation; either version 2 of the License, or
[14] Fix | Delete
(at your option) any later version.
[15] Fix | Delete
This program is distributed in the hope that it will be useful,
[16] Fix | Delete
but WITHOUT ANY WARRANTY; without even the implied warranty of
[17] Fix | Delete
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[18] Fix | Delete
GNU General Public License for more details.
[19] Fix | Delete
You should have received a copy of the GNU General Public License
[20] Fix | Delete
along with this program; if not, write to the Free Software
[21] Fix | Delete
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
[22] Fix | Delete
*/
[23] Fix | Delete
[24] Fix | Delete
if ( ! defined( 'CTF_URL' ) ) {
[25] Fix | Delete
// Use smash Twitter if API V2 credentials are not defined.
[26] Fix | Delete
$ctf_options = get_option('ctf_options', array());
[27] Fix | Delete
define( 'CTF_DOING_SMASH_TWITTER', empty($ctf_options['consumer_key']) && empty($ctf_options['consumer_secret']));
[28] Fix | Delete
[29] Fix | Delete
define( 'CTF_URL', plugin_dir_path( __FILE__ ) );
[30] Fix | Delete
define( 'CTF_VERSION', '2.2.2' );
[31] Fix | Delete
define( 'CTF_TITLE', 'Custom Twitter Feeds' );
[32] Fix | Delete
define( 'CTF_JS_URL', plugins_url( '/js/ctf-scripts.min.js?ver=' . CTF_VERSION , __FILE__ ) );
[33] Fix | Delete
define( 'CTF_PRODUCT_NAME', 'Custom Twitter Feeds' );
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
if ( ! defined( 'CTF_SITE_ACCESS_TOKEN_KEY' ) ) {
[37] Fix | Delete
define( 'CTF_SITE_ACCESS_TOKEN_KEY', 'site_access_token_free' );
[38] Fix | Delete
}
[39] Fix | Delete
if ( ! defined( 'SMASH_TWITTER_URL' ) ) {
[40] Fix | Delete
define( 'SMASH_TWITTER_URL', 'https://ctf.smashballoon.com/api/' );
[41] Fix | Delete
}
[42] Fix | Delete
if ( ! defined( 'SMASH_TWITTER_TIMELINE_PATH' ) ) {
[43] Fix | Delete
define( 'SMASH_TWITTER_TIMELINE_PATH', '1.1/timeline' );
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
if ( ! defined( 'SMASH_TWITTER_URL_EXTRA_GET_PARAMS' ) ) {
[47] Fix | Delete
define( 'SMASH_TWITTER_URL_EXTRA_GET_PARAMS', '' );
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
if ( ! defined( 'OAUTH_PROCESSOR_URL' ) ) {
[51] Fix | Delete
define( 'OAUTH_PROCESSOR_URL', 'https://connect.smashballoon.com/auth/tw/' );
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( ! defined( 'CTF_PLUGIN_NAME' ) ) {
[55] Fix | Delete
define( 'CTF_PLUGIN_NAME', 'Custom Twitter Feeds' );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
// Plugin Folder Path.
[59] Fix | Delete
if ( ! defined( 'CTF_PLUGIN_DIR' ) ) {
[60] Fix | Delete
define( 'CTF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
[61] Fix | Delete
}
[62] Fix | Delete
// Plugin Folder URL.
[63] Fix | Delete
if ( ! defined( 'CTF_PLUGIN_URL' ) ) {
[64] Fix | Delete
define( 'CTF_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
[65] Fix | Delete
}
[66] Fix | Delete
// Db version.
[67] Fix | Delete
if ( ! defined( 'CTF_DBVERSION' ) ) {
[68] Fix | Delete
define( 'CTF_DBVERSION', '1.5' );
[69] Fix | Delete
}
[70] Fix | Delete
if ( ! defined( 'CTF_FEED_LOCATOR' ) ) {
[71] Fix | Delete
define( 'CTF_FEED_LOCATOR', 'ctf_feed_locator' );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
if ( ! defined( 'CTF_BUILDER_DIR' ) ) {
[75] Fix | Delete
define( 'CTF_BUILDER_DIR', CTF_PLUGIN_DIR . 'admin/builder/' );
[76] Fix | Delete
}
[77] Fix | Delete
if ( ! defined( 'CTF_BUILDER_URL' ) ) {
[78] Fix | Delete
define( 'CTF_BUILDER_URL', CTF_PLUGIN_URL . 'admin/builder/' );
[79] Fix | Delete
}
[80] Fix | Delete
if ( ! defined( 'CTF_UPLOADS_NAME' ) ) {
[81] Fix | Delete
define( 'CTF_UPLOADS_NAME', 'sb-twitter-feed-images' );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
if ( ! defined( 'CTF_PLUGIN_NAME' ) ) {
[85] Fix | Delete
define( 'CTF_PLUGIN_NAME', 'Custom Twitter Feed Free' );
[86] Fix | Delete
}
[87] Fix | Delete
if ( ! defined( 'CTF_FEEDS_POSTS_TABLE' ) ) {
[88] Fix | Delete
define( 'CTF_FEEDS_POSTS_TABLE', 'ctf_feeds_posts' );
[89] Fix | Delete
}
[90] Fix | Delete
if ( ! defined( 'CTF_POSTS_TABLE' ) ) {
[91] Fix | Delete
define( 'CTF_POSTS_TABLE', 'ctf_posts' );
[92] Fix | Delete
}
[93] Fix | Delete
if ( ! defined( 'CTF_LICENSE_URL' ) ) {
[94] Fix | Delete
define( 'CTF_LICENSE_URL', 'https://smashballoon.com/' );
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
if ( ! defined( 'CTF_PLUGIN_BASENAME' ) ) {
[98] Fix | Delete
define( 'CTF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
[102] Fix | Delete
[103] Fix | Delete
if ( version_compare( phpversion(), '5.6', '<' ) ) {
[104] Fix | Delete
if( !function_exists( 'ctf_check_php_notice' ) ){
[105] Fix | Delete
function ctf_check_php_notice(){ ?>
[106] Fix | Delete
<div class="notice notice-error">
[107] Fix | Delete
<div>
[108] Fix | Delete
<p><strong><?php echo esc_html__('Important:','custom-twitter-feeds') ?> </strong><?php echo esc_html__('Your website is using an outdated version of PHP. The Custom Twitter Feeds plugin requires PHP version 5.6 or higher and so has been temporarily deactivated.','custom-twitter-feeds') ?></p>
[109] Fix | Delete
[110] Fix | Delete
<p>
[111] Fix | Delete
<?php
[112] Fix | Delete
echo esc_html__('To continue using the plugin','custom-twitter-feeds') . ', ';
[113] Fix | Delete
[114] Fix | Delete
echo __('you can either manually reinstall the previous version of the plugin ','custom-twitter-feeds' );
[115] Fix | Delete
[116] Fix | Delete
echo esc_html__('or contact your host to request that they upgrade your PHP version to 5.6 or higher.','custom-twitter-feeds');
[117] Fix | Delete
?>
[118] Fix | Delete
</p>
[119] Fix | Delete
</div>
[120] Fix | Delete
</div>
[121] Fix | Delete
<?php
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
add_action( 'admin_notices', 'ctf_check_php_notice' );
[125] Fix | Delete
return; //Stop until PHP version is fixed
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
require_once( CTF_URL . '/inc/widget.php' );
[129] Fix | Delete
[130] Fix | Delete
require_once( CTF_URL . '/inc/admin-hooks.php' );
[131] Fix | Delete
[132] Fix | Delete
function ctf_plugin_init() {
[133] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/blocks/class-ctf-blocks.php';
[134] Fix | Delete
[135] Fix | Delete
$ctf_blocks = new CTF_Blocks();
[136] Fix | Delete
[137] Fix | Delete
if ( $ctf_blocks->allow_load() ) {
[138] Fix | Delete
$ctf_blocks->load();
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
require trailingslashit( CTF_PLUGIN_DIR ) . 'vendor/autoload.php';
[142] Fix | Delete
include_once trailingslashit( CTF_PLUGIN_DIR ) . '/inc/ctf-functions.php';
[143] Fix | Delete
[144] Fix | Delete
if ( is_admin() ) {
[145] Fix | Delete
if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0
[146] Fix | Delete
&& version_compare( get_bloginfo('version'), '4.6' , '>' ) ) {
[147] Fix | Delete
$ctf_notifications = new TwitterFeed\Admin\CTF_Notifications();
[148] Fix | Delete
$ctf_notifications->init();
[149] Fix | Delete
[150] Fix | Delete
$ctf_new_user = new TwitterFeed\Admin\CTF_New_User();
[151] Fix | Delete
$ctf_new_user->init();
[152] Fix | Delete
[153] Fix | Delete
$ctf_global_settings = new TwitterFeed\Admin\CTF_Global_Settings();
[154] Fix | Delete
$ctf_admin_notices = new TwitterFeed\Admin\CTF_Admin_Notices();
[155] Fix | Delete
$ctf_tooltip_wizard = new TwitterFeed\Builder\CTF_Tooltip_Wizard();
[156] Fix | Delete
$ctf_support = new TwitterFeed\Admin\CTF_Support();
[157] Fix | Delete
$ctf_admin_notices = new TwitterFeed\Admin\CTF_Admin_Notices();
[158] Fix | Delete
$ctf_about_us = new TwitterFeed\Admin\CTF_About_Us();
[159] Fix | Delete
[160] Fix | Delete
[161] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/addon-functions.php';
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/CTF_Upgrader.php';
[165] Fix | Delete
$ctf_upgrader = new TwitterFeed\Admin\CTF_Upgrader();
[166] Fix | Delete
$ctf_upgrader->hooks();
[167] Fix | Delete
[168] Fix | Delete
[169] Fix | Delete
$cron_update_manager = new \TwitterFeed\SmashTwitter\CronUpdaterManager();
[170] Fix | Delete
$cron_update_manager->hooks();
[171] Fix | Delete
[172] Fix | Delete
$error_reporter = new \TwitterFeed\SmashTwitter\Services\ErrorReporterService();
[173] Fix | Delete
$error_reporter->init_hooks();
[174] Fix | Delete
}
[175] Fix | Delete
add_action( 'plugins_loaded', 'ctf_plugin_init' );
[176] Fix | Delete
[177] Fix | Delete
include_once trailingslashit( CTF_PLUGIN_DIR ) . '/inc/Builder/CTF_Feed_Builder.php';
[178] Fix | Delete
[179] Fix | Delete
[180] Fix | Delete
function ctf_update_settings() {
[181] Fix | Delete
$existing_deprecated_options = get_option( 'ctf_configure' );
[182] Fix | Delete
$existing_options = get_option( 'ctf_options' );
[183] Fix | Delete
[184] Fix | Delete
update_option( 'ctf_version', CTF_VERSION );
[185] Fix | Delete
[186] Fix | Delete
if ( ! empty( $existing_deprecated_options ) && empty( $existing_options ) ) {
[187] Fix | Delete
$merged_options = $existing_deprecated_options;
[188] Fix | Delete
$merged_options = array_merge( $merged_options, get_option( 'ctf_customize', array() ) );
[189] Fix | Delete
$merged_options = array_merge( $merged_options, get_option( 'ctf_style', array() ) );
[190] Fix | Delete
[191] Fix | Delete
update_option( 'ctf_options', $merged_options );
[192] Fix | Delete
}
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
function ctf_check_for_db_updates() {
[196] Fix | Delete
[197] Fix | Delete
$db_ver = get_option( 'ctf_db_version', 0 );
[198] Fix | Delete
[199] Fix | Delete
if ( (float) $db_ver < 1.0 ) {
[200] Fix | Delete
global $wp_roles;
[201] Fix | Delete
$wp_roles->add_cap( 'administrator', 'manage_twitter_feed_options' );
[202] Fix | Delete
[203] Fix | Delete
$ctf_statuses_option = get_option( 'ctf_statuses', array() );
[204] Fix | Delete
[205] Fix | Delete
if ( ! isset( $ctf_statuses_option['first_install'] ) ) {
[206] Fix | Delete
[207] Fix | Delete
$options_set = get_option( 'ctf_options', false );
[208] Fix | Delete
[209] Fix | Delete
if ( $options_set ) {
[210] Fix | Delete
$ctf_statuses_option['first_install'] = 'from_update';
[211] Fix | Delete
} else {
[212] Fix | Delete
$ctf_statuses_option['first_install'] = time();
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
$ctf_rating_notice_option = get_option( 'ctf_rating_notice', false );
[216] Fix | Delete
[217] Fix | Delete
if ( $ctf_rating_notice_option === 'dismissed' ) {
[218] Fix | Delete
$ctf_statuses_option['rating_notice_dismissed'] = time();
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
$ctf_rating_notice_waiting = get_transient( 'custom_twitter_feeds_rating_notice_waiting' );
[222] Fix | Delete
[223] Fix | Delete
if ( $ctf_rating_notice_waiting === false
[224] Fix | Delete
&& $ctf_rating_notice_option === false ) {
[225] Fix | Delete
$time = 2 * WEEK_IN_SECONDS;
[226] Fix | Delete
set_transient( 'custom_twitter_feeds_rating_notice_waiting', 'waiting', $time );
[227] Fix | Delete
update_option( 'ctf_rating_notice', 'pending', false );
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
update_option( 'ctf_statuses', $ctf_statuses_option, false );
[231] Fix | Delete
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
update_option( 'ctf_db_version', CTF_DBVERSION );
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
if ( version_compare( $db_ver, '1.0.1', '<' ) ) {
[238] Fix | Delete
TwitterFeed\CTF_Feed_Locator::create_table();
[239] Fix | Delete
update_option( 'ctf_db_version', CTF_DBVERSION );
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
// For v2.0
[243] Fix | Delete
if ( version_compare( $db_ver, '1.4', '<' ) ) {
[244] Fix | Delete
update_option( 'ctf_db_version', CTF_DBVERSION );
[245] Fix | Delete
\TwitterFeed\Builder\CTF_Db::create_tables();
[246] Fix | Delete
$ctf_statuses_option = get_option( 'ctf_statuses', array() );
[247] Fix | Delete
$ctf_options = get_option( 'ctf_options', array() );
[248] Fix | Delete
[249] Fix | Delete
if ( ! isset( $ctf_statuses_option['first_install'] ) ) {
[250] Fix | Delete
[251] Fix | Delete
$options_set = get_option( 'ctf_options', false );
[252] Fix | Delete
[253] Fix | Delete
if ( $options_set ) {
[254] Fix | Delete
$ctf_statuses_option['first_install'] = 'from_update';
[255] Fix | Delete
} else {
[256] Fix | Delete
$ctf_statuses_option['first_install'] = time();
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
$ctf_rating_notice_option = get_option( 'ctf_rating_notice', false );
[260] Fix | Delete
[261] Fix | Delete
if ( $ctf_rating_notice_option === 'dismissed' ) {
[262] Fix | Delete
$ctf_statuses_option['rating_notice_dismissed'] = time();
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
$ctf_rating_notice_waiting = get_transient( 'custom_twitter_feeds_rating_notice_waiting' );
[266] Fix | Delete
[267] Fix | Delete
if ( $ctf_rating_notice_waiting === false
[268] Fix | Delete
&& $ctf_rating_notice_option === false ) {
[269] Fix | Delete
$time = 2 * WEEK_IN_SECONDS;
[270] Fix | Delete
set_transient( 'custom_twitter_feeds_rating_notice_waiting', 'waiting', $time );
[271] Fix | Delete
update_option( 'ctf_rating_notice', 'pending', false );
[272] Fix | Delete
}
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
//Legacy feeds
[276] Fix | Delete
$options_support_legacy = false;
[277] Fix | Delete
[278] Fix | Delete
if ( isset( $ctf_options['access_token'] ) && ! empty( $ctf_options['access_token'] ) ) {
[279] Fix | Delete
$options_support_legacy = true;
[280] Fix | Delete
$base_settings = \TwitterFeed\CTF_Settings::legacy_shortcode_atts( array(), $ctf_options );
[281] Fix | Delete
update_option( 'ctf_legacy_feed_settings', ctf_json_encode( $base_settings ), false );
[282] Fix | Delete
}
[283] Fix | Delete
// how many legacy feeds?
[284] Fix | Delete
$args = array(
[285] Fix | Delete
'html_location' => array( 'header', 'footer', 'sidebar', 'content', 'unknown' ),
[286] Fix | Delete
'group_by' => 'shortcode_atts',
[287] Fix | Delete
'page' => 1,
[288] Fix | Delete
);
[289] Fix | Delete
[290] Fix | Delete
$feeds_data = \TwitterFeed\CTF_Feed_Locator::legacy_twitter_feed_locator_query( $args );
[291] Fix | Delete
$num_legacy = count( $feeds_data );
[292] Fix | Delete
$ctf_statuses_option['support_legacy_shortcode'] = $options_support_legacy;
[293] Fix | Delete
if ( $num_legacy > 0 ) {
[294] Fix | Delete
if ( $num_legacy > 1 ) {
[295] Fix | Delete
$ctf_statuses_option['legacy_onboarding'] = array(
[296] Fix | Delete
'active' => true,
[297] Fix | Delete
'type' => 'multiple',
[298] Fix | Delete
);
[299] Fix | Delete
$ctf_statuses_option['support_legacy_shortcode'] = true;
[300] Fix | Delete
} else {
[301] Fix | Delete
$ctf_statuses_option['legacy_onboarding'] = array(
[302] Fix | Delete
'active' => true,
[303] Fix | Delete
'type' => 'single',
[304] Fix | Delete
);
[305] Fix | Delete
[306] Fix | Delete
$shortcode_atts = ! empty( $feeds_data[0] ) && $feeds_data[0]['shortcode_atts'] != '[""]' ? json_decode( $feeds_data[0]['shortcode_atts'], true ) : array();
[307] Fix | Delete
$shortcode_atts = is_array( $shortcode_atts ) ? $shortcode_atts : array();
[308] Fix | Delete
[309] Fix | Delete
$ctf_statuses_option['support_legacy_shortcode'] = $shortcode_atts;
[310] Fix | Delete
[311] Fix | Delete
$shortcode_atts['from_update'] = true;
[312] Fix | Delete
[313] Fix | Delete
$db = ctf_get_database_settings();
[314] Fix | Delete
$base_settings = \TwitterFeed\CTF_Settings::legacy_shortcode_atts( $shortcode_atts, $db );
[315] Fix | Delete
[316] Fix | Delete
$feed_saver = new \TwitterFeed\Builder\CTF_Feed_Saver( false );
[317] Fix | Delete
$feed_saver->set_data( $base_settings );
[318] Fix | Delete
[319] Fix | Delete
$feed_name = 'My Feed';
[320] Fix | Delete
$feed_saver->set_feed_name( $feed_name );
[321] Fix | Delete
[322] Fix | Delete
$new_feed_id = $feed_saver->update_or_insert();
[323] Fix | Delete
[324] Fix | Delete
$args = array(
[325] Fix | Delete
'new_feed_id' => $new_feed_id,
[326] Fix | Delete
'legacy_feed_id' => $feeds_data[0]['feed_id'],
[327] Fix | Delete
);
[328] Fix | Delete
[329] Fix | Delete
\TwitterFeed\CTF_Feed_Locator::update_legacy_to_builder( $args );
[330] Fix | Delete
}
[331] Fix | Delete
} elseif ( $num_legacy === 0 && $options_support_legacy ) {
[332] Fix | Delete
$ctf_statuses_option['support_legacy_shortcode'] = true;
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
update_option( 'ctf_statuses', $ctf_statuses_option, false );
[336] Fix | Delete
update_option( 'ctf_db_version', CTF_DBVERSION );
[337] Fix | Delete
[338] Fix | Delete
if ( ! wp_next_scheduled( 'ctf_feed_update' ) ) {
[339] Fix | Delete
wp_schedule_event( time() + 60, 'twicedaily', 'ctf_feed_update' );
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
global $wp_roles;
[343] Fix | Delete
$wp_roles->add_cap( 'administrator', 'manage_twitter_feed_options' );
[344] Fix | Delete
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
// For Smash Twitter
[348] Fix | Delete
if ( version_compare( $db_ver, '1.5', '<' ) ) {
[349] Fix | Delete
update_option( 'ctf_db_version', CTF_DBVERSION );
[350] Fix | Delete
global $wpdb;
[351] Fix | Delete
ctf_create_database_table();
[352] Fix | Delete
$table_name = $wpdb->prefix . CTF_FEEDS_POSTS_TABLE;
[353] Fix | Delete
[354] Fix | Delete
$wpdb->query( "ALTER TABLE $table_name ADD COLUMN type VARCHAR(1000) DEFAULT '' NOT NULL" );
[355] Fix | Delete
$wpdb->query( "ALTER TABLE $table_name ADD COLUMN term VARCHAR(1000) DEFAULT '' NOT NULL" );
[356] Fix | Delete
$wpdb->query( "ALTER TABLE $table_name ADD INDEX type_term (term(140),type(51))" );
[357] Fix | Delete
[358] Fix | Delete
\TwitterFeed\SmashTwitter\CronUpdaterManager::schedule_cron_job();
[359] Fix | Delete
[360] Fix | Delete
$ctf_statuses_option = get_option( 'ctf_statuses', array() );
[361] Fix | Delete
// to space out the API requests, we have the initial cron update scheduled a day + random number of hours.
[362] Fix | Delete
$ctf_statuses_option['first_cron_update'] = mt_rand(0,23) * 3600 + time() + DAY_IN_SECONDS;
[363] Fix | Delete
update_option( 'ctf_statuses', $ctf_statuses_option, false );
[364] Fix | Delete
[365] Fix | Delete
update_option( 'ctf_db_version', CTF_DBVERSION );
[366] Fix | Delete
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
}
[370] Fix | Delete
add_action( 'wp_loaded', 'ctf_check_for_db_updates' );
[371] Fix | Delete
[372] Fix | Delete
[373] Fix | Delete
/**
[374] Fix | Delete
* include the admin files only if in the admin area
[375] Fix | Delete
*/
[376] Fix | Delete
if ( is_admin() ) {
[377] Fix | Delete
[378] Fix | Delete
$ctf_version = get_option( 'ctf_version', false );
[379] Fix | Delete
[380] Fix | Delete
if ( ! $ctf_version ) {
[381] Fix | Delete
ctf_update_settings();
[382] Fix | Delete
}
[383] Fix | Delete
require_once( CTF_URL . '/inc/CtfAdmin.php' );
[384] Fix | Delete
require_once( CTF_URL . '/inc/notices.php' );
[385] Fix | Delete
[386] Fix | Delete
$admin = new CtfAdmin;
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
/**
[390] Fix | Delete
* Generates the Twitter feed wherever the shortcode is placed
[391] Fix | Delete
*
[392] Fix | Delete
* @param $atts array shortcode arguments
[393] Fix | Delete
*
[394] Fix | Delete
* @return string
[395] Fix | Delete
*/
[396] Fix | Delete
function ctf_init( $atts, $preview_settings = false ) {
[397] Fix | Delete
wp_enqueue_script( 'ctf_scripts' );
[398] Fix | Delete
$twitter_feed = TwitterFeed\CtfFeed::init( $atts, null, 0, array(), 1, $preview_settings);
[399] Fix | Delete
if ( isset( $twitter_feed->feed_options['feederror'] ) && ! empty( $twitter_feed->feed_options['feederror'] ) ) {
[400] Fix | Delete
return "<span id='ctf-no-id'>" . sprintf( __( 'No feed found with the ID %1$s. Go to the %2$sAll Feeds page%3$s and select an ID from an existing feed.', 'custom-twitter-feeds' ), esc_html( $twitter_feed->feed_options['feed'] ), '<a href="' . esc_url( admin_url( 'admin.php?page=ctf-feed-builder' ) ) . '">', '</a>' ) . '</span><br /><br />';
[401] Fix | Delete
} else {
[402] Fix | Delete
// if there is an error, display the error html, otherwise the feed
[403] Fix | Delete
if ( ! $twitter_feed->tweet_set || ($twitter_feed->missing_credentials && ! CTF_DOING_SMASH_TWITTER) || ! isset( $twitter_feed->tweet_set[0]['created_at'] ) ) {
[404] Fix | Delete
if ( ! empty( $twitter_feed->tweet_set['errors'] ) ) {
[405] Fix | Delete
$twitter_feed->maybeCacheTweets();
[406] Fix | Delete
} else {
[407] Fix | Delete
$twitter_feed->maybeCacheTweets(true);
[408] Fix | Delete
}
[409] Fix | Delete
$feed_html = '';
[410] Fix | Delete
$feed_html .= $twitter_feed->getTweetSetHtml();
[411] Fix | Delete
[412] Fix | Delete
return $feed_html;
[413] Fix | Delete
} else {
[414] Fix | Delete
if ( ! $twitter_feed->feed_options['persistentcache'] ) {
[415] Fix | Delete
$twitter_feed->maybeCacheTweets();
[416] Fix | Delete
}
[417] Fix | Delete
$feed_html = '';
[418] Fix | Delete
$feed_html .= $twitter_feed->getTweetSetHtml();
[419] Fix | Delete
[420] Fix | Delete
return $feed_html;
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
}
[424] Fix | Delete
add_shortcode( 'custom-twitter-feed', 'ctf_init' );
[425] Fix | Delete
add_shortcode( 'custom-twitter-feeds', 'ctf_init' );
[426] Fix | Delete
[427] Fix | Delete
/**
[428] Fix | Delete
* Called via ajax to get more posts after the "load more" button is clicked
[429] Fix | Delete
*/
[430] Fix | Delete
function ctf_get_more_posts() {
[431] Fix | Delete
$shortcode_data = json_decode( str_replace( '\"', '"', sanitize_text_field( $_POST['shortcode_data'] ) ), true ); // necessary to unescape quotes
[432] Fix | Delete
$last_id_data = isset( $_POST['last_id_data'] ) ? sanitize_text_field( $_POST['last_id_data'] ) : '';
[433] Fix | Delete
$num_needed = isset( $_POST['num_needed'] ) ? (int)$_POST['num_needed'] : 0;
[434] Fix | Delete
$ids_to_remove = isset( $_POST['ids_to_remove'] ) ? $_POST['ids_to_remove'] : array();
[435] Fix | Delete
$feed = isset( $_POST['v2feed'] ) ? sanitize_key( $_POST['v2feed'] ) : '';
[436] Fix | Delete
if ( empty( $shortcode_data ) ) {
[437] Fix | Delete
$shortcode_data = array();
[438] Fix | Delete
}
[439] Fix | Delete
$shortcode_data['feed'] = $feed;
[440] Fix | Delete
[441] Fix | Delete
$is_pagination = empty( $last_id_data ) ? 0 : 1;
[442] Fix | Delete
$persistent_index = isset( $_POST['persistent_index'] ) ? sanitize_text_field( $_POST['persistent_index'] ) : '';
[443] Fix | Delete
[444] Fix | Delete
$twitter_feed = TwitterFeed\CtfFeed::init( $shortcode_data, $last_id_data, $num_needed, $ids_to_remove, $persistent_index );
[445] Fix | Delete
[446] Fix | Delete
if ( ! CTF_DOING_SMASH_TWITTER && ! $twitter_feed->feed_options['persistentcache'] ) {
[447] Fix | Delete
$twitter_feed->maybeCacheTweets();
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
$atts = $shortcode_data;
[451] Fix | Delete
$feed_id = isset( $_POST['feed_id'] ) ? sanitize_text_field( $_POST['feed_id'] ) : 'unknown';
[452] Fix | Delete
$location = isset( $_POST['location'] ) && in_array( $_POST['location'], array( 'header', 'footer', 'sidebar', 'content' ), true ) ? sanitize_text_field( $_POST['location'] ) : 'unknown';
[453] Fix | Delete
$post_id = isset( $_POST['post_id'] ) && $_POST['post_id'] !== 'unknown' ? (int)$_POST['post_id'] : 'unknown';
[454] Fix | Delete
$feed_details = array(
[455] Fix | Delete
'feed_id' => $feed_id,
[456] Fix | Delete
'atts' => $atts,
[457] Fix | Delete
'location' => array(
[458] Fix | Delete
'post_id' => $post_id,
[459] Fix | Delete
'html' => $location
[460] Fix | Delete
)
[461] Fix | Delete
);
[462] Fix | Delete
[463] Fix | Delete
ctf_do_background_tasks( $feed_details );
[464] Fix | Delete
[465] Fix | Delete
echo $twitter_feed->getItemSetHtml( $is_pagination );
[466] Fix | Delete
[467] Fix | Delete
die();
[468] Fix | Delete
}
[469] Fix | Delete
add_action( 'wp_ajax_nopriv_ctf_get_more_posts', 'ctf_get_more_posts' );
[470] Fix | Delete
add_action( 'wp_ajax_ctf_get_more_posts', 'ctf_get_more_posts' );
[471] Fix | Delete
[472] Fix | Delete
function ctf_do_locator() {
[473] Fix | Delete
if ( ! isset( $_POST['feed_id'] ) || strpos( $_POST['feed_id'], 'ctf' ) === false ) {
[474] Fix | Delete
die( 'invalid feed ID');
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
$feed_id = sanitize_text_field( $_POST['feed_id'] );
[478] Fix | Delete
[479] Fix | Delete
$atts_raw = isset( $_POST['atts'] ) ? json_decode( stripslashes( $_POST['atts'] ), true ) : array();
[480] Fix | Delete
if ( is_array( $atts_raw ) ) {
[481] Fix | Delete
array_map( 'sanitize_text_field', $atts_raw );
[482] Fix | Delete
} else {
[483] Fix | Delete
$atts_raw = array();
[484] Fix | Delete
}
[485] Fix | Delete
$atts = $atts_raw; // now sanitized
[486] Fix | Delete
[487] Fix | Delete
$location = isset( $_POST['location'] ) && in_array( $_POST['location'], array( 'header', 'footer', 'sidebar', 'content' ), true ) ? sanitize_text_field( $_POST['location'] ) : 'unknown';
[488] Fix | Delete
$post_id = isset( $_POST['post_id'] ) && $_POST['post_id'] !== 'unknown' ? (int)$_POST['post_id'] : 'unknown';
[489] Fix | Delete
$feed_details = array(
[490] Fix | Delete
'feed_id' => $feed_id,
[491] Fix | Delete
'atts' => $atts,
[492] Fix | Delete
'location' => array(
[493] Fix | Delete
'post_id' => $post_id,
[494] Fix | Delete
'html' => $location
[495] Fix | Delete
)
[496] Fix | Delete
);
[497] Fix | Delete
[498] Fix | Delete
ctf_do_background_tasks( $feed_details );
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function