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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/custom-t.../inc
File: CTF_Feed.php
} elseif ( isset( $tweet['full_text'] ) ) {
[1000] Fix | Delete
$tweet_text = $tweet['full_text'];
[1001] Fix | Delete
} elseif ( isset( $tweet['text'] ) ) {
[1002] Fix | Delete
$tweet_text = $tweet['text'];
[1003] Fix | Delete
} else {
[1004] Fix | Delete
$tweet_text = '';
[1005] Fix | Delete
}
[1006] Fix | Delete
$tweet_text = ' ' . preg_replace( '/[,.!?:;"]+/', '', $tweet_text ) . ' '; // spaces added so that we can use strpos instead of regex to find words
[1007] Fix | Delete
$tweet_text = strtolower( preg_replace( '/[\n]+/', ' ', $tweet_text ) );
[1008] Fix | Delete
// don't bother with filtering process if both filters are empty
[1009] Fix | Delete
if ( ! empty( $good_text ) || ! empty( $bad_text ) ) {
[1010] Fix | Delete
if ( $filter_and_or == 'and' && ! empty( $good_text ) && ! empty( $bad_text ) ) {
[1011] Fix | Delete
if ( CTF_Feed::hasGoodText( $good_text, $includewords_any_all, $tweet_text, true ) && CTF_Feed::hasNoBadText( $bad_text, 'any', $tweet_text, true ) ) {
[1012] Fix | Delete
$return = false;
[1013] Fix | Delete
} else {
[1014] Fix | Delete
$return = true;
[1015] Fix | Delete
}
[1016] Fix | Delete
} else {
[1017] Fix | Delete
if ( CTF_Feed::hasGoodText( $good_text, $includewords_any_all, $tweet_text, false ) || CTF_Feed::hasNoBadText( $bad_text, $excludewords_any_all, $tweet_text, false ) ) {
[1018] Fix | Delete
$return = false;
[1019] Fix | Delete
} else {
[1020] Fix | Delete
$return = true;
[1021] Fix | Delete
}
[1022] Fix | Delete
}
[1023] Fix | Delete
}
[1024] Fix | Delete
[1025] Fix | Delete
$return = apply_filters( 'ctf_filter_out_tweet', $return, $tweet_text, $tweet );
[1026] Fix | Delete
[1027] Fix | Delete
return $return;
[1028] Fix | Delete
}
[1029] Fix | Delete
[1030] Fix | Delete
public static function hasGoodText( $good_text, $any_or_all, $tweet_text, $default )
[1031] Fix | Delete
{
[1032] Fix | Delete
if ( empty( $good_text ) ) { // don't factor in the includewords if there aren't any
[1033] Fix | Delete
return $default;
[1034] Fix | Delete
} else {
[1035] Fix | Delete
$encoded_text = ' ' . str_replace( array( '+', '%0A' ), ' ', urlencode( str_replace( array( '#', '@' ), array( ' HASHTAG', ' MENTION' ), strtolower( $tweet_text ) ) ) ) . ' ';
[1036] Fix | Delete
[1037] Fix | Delete
if ( $any_or_all == 'any' ) {
[1038] Fix | Delete
// as soon as we find any of the includewords, stop searching and return true
[1039] Fix | Delete
foreach ( $good_text as $good ) {
[1040] Fix | Delete
$converted_includeword = trim( str_replace('+', ' ', urlencode( str_replace( array( '#', '@' ), array( ' HASHTAG', ' MENTION' ), strtolower( $good ) ) ) ) );
[1041] Fix | Delete
[1042] Fix | Delete
if ( preg_match('/\b'.$converted_includeword.'\b/i', $encoded_text, $matches ) ) {
[1043] Fix | Delete
return true;
[1044] Fix | Delete
}
[1045] Fix | Delete
}
[1046] Fix | Delete
// if foreach finishes without finding any matches
[1047] Fix | Delete
return false;
[1048] Fix | Delete
} else {
[1049] Fix | Delete
// to make sure all of the includewords are present, keep a count of
[1050] Fix | Delete
// how many of the words are detected and compare it to the number that's needed
[1051] Fix | Delete
$good_text_matches = 0;
[1052] Fix | Delete
$number_of_good_text_to_look_for = count( $good_text );
[1053] Fix | Delete
foreach ( $good_text as $good ) {
[1054] Fix | Delete
$converted_includeword = trim( str_replace('+', ' ', urlencode( str_replace( array( '#', '@' ), array( ' HASHTAG', ' MENTION' ), strtolower( $good ) ) ) ) );
[1055] Fix | Delete
[1056] Fix | Delete
if ( preg_match('/\b'.$converted_includeword.'\b/i', $encoded_text, $matches ) ) {
[1057] Fix | Delete
$good_text_matches++;
[1058] Fix | Delete
}
[1059] Fix | Delete
[1060] Fix | Delete
}
[1061] Fix | Delete
if ( $good_text_matches >= $number_of_good_text_to_look_for ) {
[1062] Fix | Delete
return true;
[1063] Fix | Delete
} else {
[1064] Fix | Delete
return false;
[1065] Fix | Delete
}
[1066] Fix | Delete
}
[1067] Fix | Delete
}
[1068] Fix | Delete
[1069] Fix | Delete
}
[1070] Fix | Delete
[1071] Fix | Delete
/**
[1072] Fix | Delete
* if a filter is applied to this feed, check and see if this tweet needs to
[1073] Fix | Delete
* or contains the excludewords text
[1074] Fix | Delete
*
[1075] Fix | Delete
* @param $bad_text array words the tweet cannot have to be included in the feed
[1076] Fix | Delete
* @param $any_or_all enum whether any or all of the bad text words need to be included
[1077] Fix | Delete
* @param $tweet_text string content text of the tweet
[1078] Fix | Delete
* @param $default bool the default return type if nothing is set
[1079] Fix | Delete
* @return bool whether the tweet meets the requirements for having no bad text
[1080] Fix | Delete
*/
[1081] Fix | Delete
public static function hasNoBadText( $bad_text, $any_or_all, $tweet_text, $default )
[1082] Fix | Delete
{
[1083] Fix | Delete
if ( empty( $bad_text ) ) { // don't factor in the excludewords if there aren't any
[1084] Fix | Delete
return $default;
[1085] Fix | Delete
} else {
[1086] Fix | Delete
$encoded_text = ' ' . str_replace( array( '+', '%0A' ), ' ', urlencode( str_replace( array( '#', '@' ), array( ' HASHTAG', ' MENTION' ), strtolower( $tweet_text ) ) ) ) . ' ';
[1087] Fix | Delete
[1088] Fix | Delete
if ( $any_or_all == 'any' ) {
[1089] Fix | Delete
// as soon as we find any of the excludewords, stop searching and return false
[1090] Fix | Delete
foreach ( $bad_text as $bad ) {
[1091] Fix | Delete
if ( empty( $bad ) ) {
[1092] Fix | Delete
return true;
[1093] Fix | Delete
}
[1094] Fix | Delete
$converted_excludeword = trim( str_replace('+', ' ', urlencode( str_replace( array( '#', '@' ), array( ' HASHTAG', ' MENTION' ), strtolower( $bad ) ) ) ) );
[1095] Fix | Delete
if ( preg_match('/\b'.$converted_excludeword.'\b/i', $encoded_text, $matches ) ) {
[1096] Fix | Delete
return false;
[1097] Fix | Delete
}
[1098] Fix | Delete
}
[1099] Fix | Delete
// if foreach finishes without finding any matches
[1100] Fix | Delete
return true;
[1101] Fix | Delete
} else {
[1102] Fix | Delete
// under this circumstance, all excludewords need to be present to remove
[1103] Fix | Delete
// the tweet so a count is kept and compared to the number of words
[1104] Fix | Delete
$bad_text_matches = 0;
[1105] Fix | Delete
$number_of_bad_text_to_look_for = count( $bad_text );
[1106] Fix | Delete
foreach ( $bad_text as $bad ) {
[1107] Fix | Delete
$converted_excludeword = trim( str_replace('+', ' ', urlencode( str_replace( '#', 'HASHTAG', strtolower( $bad ) ) ) ) );
[1108] Fix | Delete
[1109] Fix | Delete
if ( preg_match('/\b'.$converted_excludeword.'\b/i', $encoded_text, $matches ) ) {
[1110] Fix | Delete
$bad_text_matches++;
[1111] Fix | Delete
}
[1112] Fix | Delete
[1113] Fix | Delete
}
[1114] Fix | Delete
if ( $bad_text_matches >= $number_of_bad_text_to_look_for ) {
[1115] Fix | Delete
return false;
[1116] Fix | Delete
} else {
[1117] Fix | Delete
return true;
[1118] Fix | Delete
}
[1119] Fix | Delete
}
[1120] Fix | Delete
}
[1121] Fix | Delete
[1122] Fix | Delete
}
[1123] Fix | Delete
[1124] Fix | Delete
public static function removeStringFromText( $string, $text, $expanded_url = '' ) {
[1125] Fix | Delete
$exceptions = array( '://fb.me/' );
[1126] Fix | Delete
[1127] Fix | Delete
if ( $expanded_url !== '' ) {
[1128] Fix | Delete
[1129] Fix | Delete
foreach ( $exceptions as $exception ) {
[1130] Fix | Delete
[1131] Fix | Delete
if ( strpos( $expanded_url, $exception ) !== false ) {
[1132] Fix | Delete
return str_replace( $string, $expanded_url, $text );
[1133] Fix | Delete
}
[1134] Fix | Delete
[1135] Fix | Delete
}
[1136] Fix | Delete
[1137] Fix | Delete
}
[1138] Fix | Delete
[1139] Fix | Delete
return str_replace( $string, '', $text );
[1140] Fix | Delete
}
[1141] Fix | Delete
[1142] Fix | Delete
public static function maybeGetTwitterCardData( $url, $id ) {
[1143] Fix | Delete
if ( ! ctf_is_pro_version() ) {
[1144] Fix | Delete
return false;
[1145] Fix | Delete
}
[1146] Fix | Delete
$url_key = str_replace('&','038',$url);
[1147] Fix | Delete
$url_key = preg_replace( '~[^a-zA-Z0-9]+~', '', $url_key );
[1148] Fix | Delete
[1149] Fix | Delete
$tc_data = get_option( 'ctf_twitter_cards', array() );
[1150] Fix | Delete
[1151] Fix | Delete
$card = false;
[1152] Fix | Delete
if ( isset( $tc_data[ $url_key ] ) ) {
[1153] Fix | Delete
$card = $tc_data[ $url_key ];
[1154] Fix | Delete
} elseif ( isset( $tc_data[ $id ] ) ) {
[1155] Fix | Delete
$card = $tc_data[ $id ];
[1156] Fix | Delete
}
[1157] Fix | Delete
[1158] Fix | Delete
if ( $card && ! isset( $card['local'] ) ) {
[1159] Fix | Delete
$card['local'] = CTF_Twitter_Card_Manager::add_local_image( $card, $id );
[1160] Fix | Delete
}
[1161] Fix | Delete
[1162] Fix | Delete
return $card;
[1163] Fix | Delete
}
[1164] Fix | Delete
[1165] Fix | Delete
public function set_next_pages( $next_pages ) {
[1166] Fix | Delete
$this->next_pages = $next_pages;
[1167] Fix | Delete
}
[1168] Fix | Delete
[1169] Fix | Delete
private function merge_posts( $post_sets, $settings ) {
[1170] Fix | Delete
$merged_posts = array();
[1171] Fix | Delete
$settings['sortby'] = isset( $settings['sortby'] ) ? $settings['sortby'] : 'date';
[1172] Fix | Delete
[1173] Fix | Delete
if ( $settings['sortby'] === 'alternate' ) {
[1174] Fix | Delete
// don't bother merging posts if there is only one post set
[1175] Fix | Delete
if ( isset( $post_sets[1] ) ) {
[1176] Fix | Delete
$min_cycles = max( 1, (int)$settings['num'] );
[1177] Fix | Delete
for( $i = 0; $i <= $min_cycles; $i++ ) {
[1178] Fix | Delete
foreach ( $post_sets as $post_set ) {
[1179] Fix | Delete
if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
[1180] Fix | Delete
$merged_posts[] = $post_set[ $i ];
[1181] Fix | Delete
}
[1182] Fix | Delete
}
[1183] Fix | Delete
}
[1184] Fix | Delete
} else {
[1185] Fix | Delete
$merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
[1186] Fix | Delete
}
[1187] Fix | Delete
} elseif ( $settings['sortby'] === 'api' ) {
[1188] Fix | Delete
if ( isset( $post_sets[0] ) ) {
[1189] Fix | Delete
foreach ( $post_sets as $post_set ) {
[1190] Fix | Delete
$merged_posts = array_merge( $merged_posts, $post_set );
[1191] Fix | Delete
}
[1192] Fix | Delete
}
[1193] Fix | Delete
} else {
[1194] Fix | Delete
// don't bother merging posts if there is only one post set
[1195] Fix | Delete
if ( isset( $post_sets[1] ) ) {
[1196] Fix | Delete
foreach ( $post_sets as $post_set ) {
[1197] Fix | Delete
$merged_posts = array_merge( $merged_posts, $post_set );
[1198] Fix | Delete
}
[1199] Fix | Delete
} else {
[1200] Fix | Delete
$merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
[1201] Fix | Delete
}
[1202] Fix | Delete
}
[1203] Fix | Delete
[1204] Fix | Delete
[1205] Fix | Delete
return $merged_posts;
[1206] Fix | Delete
}
[1207] Fix | Delete
[1208] Fix | Delete
/**
[1209] Fix | Delete
* Connects to the Instagram API and records returned data
[1210] Fix | Delete
*
[1211] Fix | Delete
* @param $settings
[1212] Fix | Delete
* @param array $feed_types_and_terms organized settings related to feed data
[1213] Fix | Delete
* (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
[1214] Fix | Delete
* @param array $connected_accounts_for_feed connected account data for the
[1215] Fix | Delete
* feed types and terms
[1216] Fix | Delete
*
[1217] Fix | Delete
* @since 2.0/5.0
[1218] Fix | Delete
* @since 2.2/5.3 added logic to append bio data from the related
[1219] Fix | Delete
* connected account if not available in the API response
[1220] Fix | Delete
*/
[1221] Fix | Delete
public function set_remote_header_data( $settings, $feed_types_and_terms ) {
[1222] Fix | Delete
$this->header_data = false;
[1223] Fix | Delete
$endpoint = 'accountlookup';
[1224] Fix | Delete
if ( $settings['type'] === 'usertimeline' ) {
[1225] Fix | Delete
$endpoint = 'userslookup';
[1226] Fix | Delete
}
[1227] Fix | Delete
[1228] Fix | Delete
// Only can be set in the options page
[1229] Fix | Delete
$request_settings = array(
[1230] Fix | Delete
'consumer_key' => $settings['consumer_key'],
[1231] Fix | Delete
'consumer_secret' => $settings['consumer_secret'],
[1232] Fix | Delete
'access_token' => $settings['access_token'],
[1233] Fix | Delete
'access_token_secret' => $settings['access_token_secret'],
[1234] Fix | Delete
);
[1235] Fix | Delete
[1236] Fix | Delete
$get_fields = $this->setGetFieldsArray( $endpoint, $settings['screenname'], $settings );
[1237] Fix | Delete
// actual connection
[1238] Fix | Delete
$twitter_connect = new CtfOauthConnect( $request_settings, $endpoint );
[1239] Fix | Delete
$twitter_connect->setUrlBase();
[1240] Fix | Delete
$twitter_connect->setGetFields( $get_fields );
[1241] Fix | Delete
$twitter_connect->setRequestMethod( $settings['request_method'] );
[1242] Fix | Delete
[1243] Fix | Delete
$request_results = $twitter_connect->performRequest();
[1244] Fix | Delete
[1245] Fix | Delete
$header_json = isset( $request_results->json ) ? $request_results->json : false;
[1246] Fix | Delete
[1247] Fix | Delete
$header_data = json_decode( $header_json, true );
[1248] Fix | Delete
[1249] Fix | Delete
$this->header_data = $header_data;
[1250] Fix | Delete
}
[1251] Fix | Delete
[1252] Fix | Delete
protected function setGetFieldsArray( $end_point, $feed_term, $settings )
[1253] Fix | Delete
{
[1254] Fix | Delete
$feed_type = $end_point;
[1255] Fix | Delete
[1256] Fix | Delete
$get_fields = array();
[1257] Fix | Delete
[1258] Fix | Delete
$get_fields['tweet_mode'] = 'extended';
[1259] Fix | Delete
[1260] Fix | Delete
if ( $feed_type === 'usertimeline' ) {
[1261] Fix | Delete
if ( ! empty ( $feed_term ) ) {
[1262] Fix | Delete
$get_fields['screen_name'] = $feed_term;
[1263] Fix | Delete
}
[1264] Fix | Delete
if ( $settings['includereplies'] || $settings['selfreplies'] ) {
[1265] Fix | Delete
$get_fields['exclude_replies'] = 'false';
[1266] Fix | Delete
} else {
[1267] Fix | Delete
$get_fields['exclude_replies'] = 'true';
[1268] Fix | Delete
}
[1269] Fix | Delete
}
[1270] Fix | Delete
[1271] Fix | Delete
if ( $feed_type === 'hometimeline' ) {
[1272] Fix | Delete
if ( $settings['includereplies'] || $settings['selfreplies'] ) {
[1273] Fix | Delete
$get_fields['exclude_replies'] = 'false';
[1274] Fix | Delete
} else {
[1275] Fix | Delete
$get_fields['exclude_replies'] = 'true';
[1276] Fix | Delete
}
[1277] Fix | Delete
}
[1278] Fix | Delete
[1279] Fix | Delete
if ( $feed_type === 'search' || $feed_type === 'hashtag' ) {
[1280] Fix | Delete
$get_fields['q'] = $feed_term;
[1281] Fix | Delete
}
[1282] Fix | Delete
[1283] Fix | Delete
if ( $feed_type === 'lists' ) {
[1284] Fix | Delete
if ( ! empty ( $feed_term ) ) {
[1285] Fix | Delete
$get_fields['list_id'] = $feed_term;
[1286] Fix | Delete
}
[1287] Fix | Delete
}
[1288] Fix | Delete
[1289] Fix | Delete
if ( $feed_type === 'userslookup' ) {
[1290] Fix | Delete
if ( ! empty ( $feed_term ) ) {
[1291] Fix | Delete
$get_fields['screen_name'] = $feed_term;
[1292] Fix | Delete
}
[1293] Fix | Delete
}
[1294] Fix | Delete
[1295] Fix | Delete
return $get_fields;
[1296] Fix | Delete
}
[1297] Fix | Delete
[1298] Fix | Delete
[1299] Fix | Delete
/**
[1300] Fix | Delete
* Stores feed data in a transient for a specified time
[1301] Fix | Delete
*
[1302] Fix | Delete
* @param int $cache_time
[1303] Fix | Delete
* @param bool $save_backup
[1304] Fix | Delete
*
[1305] Fix | Delete
* @since 2.0/5.0
[1306] Fix | Delete
* @since 2.0/5.1 duplicate posts removed
[1307] Fix | Delete
*/
[1308] Fix | Delete
public function cache_feed_data( $cache_time, $save_backup = true ) {
[1309] Fix | Delete
if ( ! empty( $this->post_data ) || ! empty( $this->next_pages ) ) {
[1310] Fix | Delete
$this->remove_duplicate_posts();
[1311] Fix | Delete
$this->trim_posts_to_max();
[1312] Fix | Delete
[1313] Fix | Delete
$to_cache = array(
[1314] Fix | Delete
'data' => $this->post_data,
[1315] Fix | Delete
'pagination' => $this->next_pages
[1316] Fix | Delete
);
[1317] Fix | Delete
[1318] Fix | Delete
$this->cache->set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
[1319] Fix | Delete
[1320] Fix | Delete
if ( $save_backup ) {
[1321] Fix | Delete
update_option( $this->backup_feed_transient_name, wp_json_encode( $to_cache ), false );
[1322] Fix | Delete
}
[1323] Fix | Delete
} else {
[1324] Fix | Delete
$this->add_report( 'no data not caching' );
[1325] Fix | Delete
}
[1326] Fix | Delete
}
[1327] Fix | Delete
[1328] Fix | Delete
/**
[1329] Fix | Delete
* Stores header data for a specified time as a transient
[1330] Fix | Delete
*
[1331] Fix | Delete
* @param int $cache_time
[1332] Fix | Delete
* @param bool $save_backup
[1333] Fix | Delete
*
[1334] Fix | Delete
* @since 2.0/5.0
[1335] Fix | Delete
*/
[1336] Fix | Delete
public function cache_header_data( $cache_time, $save_backup = true ) {
[1337] Fix | Delete
if ( $this->header_data ) {
[1338] Fix | Delete
$this->cache->set_transient( $this->header_transient_name, wp_json_encode( $this->header_data ), $cache_time );
[1339] Fix | Delete
[1340] Fix | Delete
if ( $save_backup ) {
[1341] Fix | Delete
update_option( $this->backup_header_transient_name, wp_json_encode( $this->header_data ), false );
[1342] Fix | Delete
}
[1343] Fix | Delete
}
[1344] Fix | Delete
}
[1345] Fix | Delete
[1346] Fix | Delete
/**
[1347] Fix | Delete
* Determines if pagination can and should be used based on settings and available feed data
[1348] Fix | Delete
*
[1349] Fix | Delete
* @param array $settings
[1350] Fix | Delete
* @param int $offset
[1351] Fix | Delete
*
[1352] Fix | Delete
* @return bool
[1353] Fix | Delete
*
[1354] Fix | Delete
* @since 2.0/5.0
[1355] Fix | Delete
*/
[1356] Fix | Delete
public function should_use_pagination( $settings, $offset = 0 ) {
[1357] Fix | Delete
[1358] Fix | Delete
if ( $settings['minnum'] < 1 ) {
[1359] Fix | Delete
$this->add_report( 'minnum too small' );
[1360] Fix | Delete
[1361] Fix | Delete
return false;
[1362] Fix | Delete
}
[1363] Fix | Delete
$posts_available = count( $this->post_data ) - ($offset + $settings['minnum']);
[1364] Fix | Delete
$show_loadmore_button_by_settings = ($settings['showbutton'] == 'on' || $settings['showbutton'] == 'true' || $settings['showbutton'] == true ) && $settings['showbutton'] !== 'false';
[1365] Fix | Delete
[1366] Fix | Delete
if ( $show_loadmore_button_by_settings ) {
[1367] Fix | Delete
if ( $posts_available > 0 ) {
[1368] Fix | Delete
$this->add_report( 'do pagination, posts available' );
[1369] Fix | Delete
return true;
[1370] Fix | Delete
}
[1371] Fix | Delete
$pages = $this->next_pages;
[1372] Fix | Delete
[1373] Fix | Delete
if ( $pages && ! $this->should_use_backup() ) {
[1374] Fix | Delete
foreach ( $pages as $page ) {
[1375] Fix | Delete
if ( ! empty( $page ) ) {
[1376] Fix | Delete
return true;
[1377] Fix | Delete
}
[1378] Fix | Delete
}
[1379] Fix | Delete
}
[1380] Fix | Delete
[1381] Fix | Delete
}
[1382] Fix | Delete
[1383] Fix | Delete
[1384] Fix | Delete
$this->add_report( 'no pagination, no posts available' );
[1385] Fix | Delete
[1386] Fix | Delete
return false;
[1387] Fix | Delete
}
[1388] Fix | Delete
[1389] Fix | Delete
/**
[1390] Fix | Delete
* Overwritten in the Pro version
[1391] Fix | Delete
*
[1392] Fix | Delete
* @param $feed_types_and_terms
[1393] Fix | Delete
*
[1394] Fix | Delete
* @return string
[1395] Fix | Delete
*
[1396] Fix | Delete
* @since 2.1/5.2
[1397] Fix | Delete
*/
[1398] Fix | Delete
public function get_first_user( $feed_types_and_terms ) {
[1399] Fix | Delete
if ( isset( $feed_types_and_terms['users'][0] ) ) {
[1400] Fix | Delete
return $feed_types_and_terms['users'][0][1];
[1401] Fix | Delete
} else {
[1402] Fix | Delete
return '';
[1403] Fix | Delete
}
[1404] Fix | Delete
}
[1405] Fix | Delete
[1406] Fix | Delete
/**
[1407] Fix | Delete
* Adds recorded strings to an array
[1408] Fix | Delete
*
[1409] Fix | Delete
* @param $to_add
[1410] Fix | Delete
*
[1411] Fix | Delete
* @since 2.0/5.0
[1412] Fix | Delete
*/
[1413] Fix | Delete
public function add_report( $to_add ) {
[1414] Fix | Delete
$this->report[] = $to_add;
[1415] Fix | Delete
}
[1416] Fix | Delete
[1417] Fix | Delete
/**
[1418] Fix | Delete
* @return array
[1419] Fix | Delete
*
[1420] Fix | Delete
* @since 2.0/5.0
[1421] Fix | Delete
*/
[1422] Fix | Delete
public function get_report() {
[1423] Fix | Delete
return $this->report;
[1424] Fix | Delete
}
[1425] Fix | Delete
[1426] Fix | Delete
/**
[1427] Fix | Delete
* Used for filtering a single API request worth of posts
[1428] Fix | Delete
*
[1429] Fix | Delete
* Overwritten in the Pro version
[1430] Fix | Delete
*
[1431] Fix | Delete
* @param array $post_set a single set of post data from the api
[1432] Fix | Delete
*
[1433] Fix | Delete
* @return mixed|array
[1434] Fix | Delete
*
[1435] Fix | Delete
* @since 2.0/5.0
[1436] Fix | Delete
*/
[1437] Fix | Delete
protected function filter_posts( $post_set, $settings = array() ) {
[1438] Fix | Delete
// array_unique( $post_set, SORT_REGULAR);
[1439] Fix | Delete
[1440] Fix | Delete
return $post_set;
[1441] Fix | Delete
}
[1442] Fix | Delete
[1443] Fix | Delete
protected function handle_no_posts_found( $settings = array(), $feed_types_and_terms = array() ) {
[1444] Fix | Delete
[1445] Fix | Delete
}
[1446] Fix | Delete
[1447] Fix | Delete
protected function remove_duplicate_posts() {
[1448] Fix | Delete
$posts = $this->post_data;
[1449] Fix | Delete
$ids_in_feed = array();
[1450] Fix | Delete
$non_duplicate_posts = array();
[1451] Fix | Delete
$removed = array();
[1452] Fix | Delete
[1453] Fix | Delete
foreach ( $posts as $post ) {
[1454] Fix | Delete
$post_id = CTF_Parse::get_post_id( $post );
[1455] Fix | Delete
if ( ! in_array( $post_id, $ids_in_feed, true ) ) {
[1456] Fix | Delete
$ids_in_feed[] = $post_id;
[1457] Fix | Delete
$non_duplicate_posts[] = $post;
[1458] Fix | Delete
} else {
[1459] Fix | Delete
$removed[] = $post_id;
[1460] Fix | Delete
}
[1461] Fix | Delete
}
[1462] Fix | Delete
[1463] Fix | Delete
$this->add_report( 'removed duplicates: ' . implode(', ', $removed ) );
[1464] Fix | Delete
$this->set_post_data( $non_duplicate_posts );
[1465] Fix | Delete
}
[1466] Fix | Delete
[1467] Fix | Delete
public static function parse_api_card_data( $data ) {
[1468] Fix | Delete
$return = array(
[1469] Fix | Delete
'twitter:title' => '',
[1470] Fix | Delete
'twitter:description' => '',
[1471] Fix | Delete
'twitter:image' => '',
[1472] Fix | Delete
'twitter:site' => '',
[1473] Fix | Delete
'twitter:card' => '',
[1474] Fix | Delete
[1475] Fix | Delete
);
[1476] Fix | Delete
[1477] Fix | Delete
if ( ! empty( $data['name'] ) ) {
[1478] Fix | Delete
$return['twitter:card'] = $data['name'];
[1479] Fix | Delete
}
[1480] Fix | Delete
[1481] Fix | Delete
if ( ! empty( $data['url'] ) ) {
[1482] Fix | Delete
$return['twitter:site'] = $data['url'];
[1483] Fix | Delete
}
[1484] Fix | Delete
[1485] Fix | Delete
if ( ! empty( $data['binding_values']['title']['string_value'] ) ) {
[1486] Fix | Delete
$return['twitter:title'] = $data['binding_values']['title']['string_value'];
[1487] Fix | Delete
}
[1488] Fix | Delete
[1489] Fix | Delete
if ( ! empty( $data['binding_values']['description']['string_value'] ) ) {
[1490] Fix | Delete
$return['twitter:description'] = $data['binding_values']['description']['string_value'];
[1491] Fix | Delete
}
[1492] Fix | Delete
if ( ! empty( $data['binding_values']['thumbnail_image_large']['image_value']['url'] ) ) {
[1493] Fix | Delete
$return['twitter:image'] = $data['binding_values']['thumbnail_image_large']['image_value']['url'];
[1494] Fix | Delete
} elseif ( ! empty( $data['binding_values']['thumbnail_image']['image_value']['url'] ) ) {
[1495] Fix | Delete
$return['twitter:image'] = $data['binding_values']['thumbnail_image']['image_value']['url'];
[1496] Fix | Delete
} elseif ( ! empty( $data['binding_values']['thumbnail_image_small']['image_value']['url'] ) ) {
[1497] Fix | Delete
$return['twitter:image'] = $data['binding_values']['thumbnail_image_small']['image_value']['url'];
[1498] Fix | Delete
}
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function