PluginProbe ʕ •ᴥ•ʔ
Custom Twitter Feeds – A Tweets Widget or X Feed Widget / 2.7.0
Custom Twitter Feeds – A Tweets Widget or X Feed Widget v2.7.0
2.8.0 2.7.0 2.6.1 2.6.0 1.0 1.0.1 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.5 1.5.1 1.6 1.6.1 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.1.2 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.5.4 2.5.5 trunk
custom-twitter-feeds / inc / Admin / CTF_Support.php
custom-twitter-feeds / inc / Admin Last commit date
Traits 1 month ago CTF_About_Us.php 1 month ago CTF_Admin_Notices.php 1 month ago CTF_Cache_Handler.php 1 month ago CTF_Global_Settings.php 1 month ago CTF_HTTP_Request.php 1 month ago CTF_New_User.php 1 month ago CTF_Notifications.php 1 month ago CTF_Response.php 1 month ago CTF_Support.php 1 month ago CTF_Upgrader.php 1 month ago CTF_View.php 1 month ago PluginSilentUpgrader.php 1 month ago PluginSilentUpgraderSkin.php 1 month ago SB_Twitter_Cache.php 1 month ago addon-functions.php 1 month ago class-install-skin.php 1 month ago
CTF_Support.php
792 lines
1 <?php
2
3 /**
4 * The Settings Page
5 *
6 * @since 2.0
7 */
8
9 namespace TwitterFeed\Admin;
10 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
12 use TwitterFeed\Admin\CTF_View;
13 use TwitterFeed\Admin\CTF_Response;
14 use TwitterFeed\Builder\CTF_Db;
15 //use TwitterFeed\CTF_Feed_Locator;
16 use TwitterFeed\Builder\CTF_Feed_Builder;
17 //use TwitterFeed\CTF_GDPR_Integrations;
18 use TwitterFeed\Builder\CTF_Feed_Saver_Manager;
19
20 class CTF_Support {
21 /**
22 * Admin menu page slug.
23 *
24 * @since 2.0
25 *
26 * @var string
27 */
28 const SLUG = 'ctf-support';
29
30 /**
31 * Initializing the class
32 *
33 * @since 2.0
34 */
35 function __construct(){
36 $this->init();
37 }
38
39 /**
40 * Determining if the user is viewing the our page, if so, party on.
41 *
42 * @since 2.0
43 */
44 public function init() {
45 if ( ! is_admin() ) {
46 return;
47 }
48
49 add_action( 'admin_menu', [ $this, 'register_menu' ] );
50 add_action( 'wp_ajax_ctf_export_settings_json', [$this, 'ctf_export_settings_json'] );
51 }
52
53 /**
54 * Register Menu.
55 *
56 * @since 2.0
57 */
58 function register_menu() {
59 $cap = ctf_get_manage_options_cap();
60
61 $support_page = add_submenu_page(
62 'custom-twitter-feeds',
63 __( 'Support', 'custom-twitter-feeds' ),
64 __( 'Support', 'custom-twitter-feeds' ),
65 $cap,
66 self::SLUG,
67 [$this, 'support_page'],
68 3
69 );
70 add_action( 'load-' . $support_page, [$this,'support_page_enqueue_assets']);
71 }
72
73 /**
74 * Enqueue Extension CSS & Script.
75 *
76 * Loads only for Extension page
77 *
78 * @since 2.0
79 */
80 public function support_page_enqueue_assets(){
81 if( ! get_current_screen() ) {
82 return;
83 }
84 $screen = get_current_screen();
85
86 if ( ! 'twitter-feed_page_ctf-support' === $screen->id ) {
87 return;
88 }
89
90 wp_enqueue_style(
91 'ctf-fira-code-font',
92 'https://fonts.googleapis.com/css2?family=Fira+Code&display=swap',
93 false,
94 CTF_VERSION
95 );
96
97 wp_enqueue_style(
98 'support-style',
99 CTF_PLUGIN_URL . 'admin/assets/css/support.css',
100 false,
101 CTF_VERSION
102 );
103
104 wp_enqueue_script(
105 'vue-main',
106 'https://cdn.jsdelivr.net/npm/vue@2.6.12',
107 null,
108 '2.6.12',
109 true
110 );
111
112 wp_enqueue_script(
113 'support-app',
114 CTF_PLUGIN_URL.'admin/assets/js/support.js',
115 null,
116 CTF_VERSION,
117 true
118 );
119
120 $ctf_support = $this->page_data();
121
122 wp_localize_script(
123 'support-app',
124 'ctf_support',
125 $ctf_support
126 );
127 }
128
129 /**
130 * Page Data to use in front end
131 *
132 * @since 2.0
133 *
134 * @return array
135 */
136 public function page_data() {
137 $exported_feeds = CTF_Db::feeds_query();
138 $feeds = array();
139 foreach( $exported_feeds as $feed_id => $feed ) {
140 $feeds[] = array(
141 'id' => $feed['id'],
142 'name' => $feed['feed_name']
143 );
144 }
145
146 $return = array(
147 'admin_url' => admin_url(),
148 'ajax_handler' => admin_url( 'admin-ajax.php' ),
149 'nonce' => wp_create_nonce( 'ctf-admin' ),
150 'links' => \TwitterFeed\Builder\CTF_Feed_Builder::get_links_with_utm(),
151 'supportPageUrl' => admin_url( 'admin.php?page=ctf-support' ),
152 'siteSearchUrl' => 'https://smashballoon.com/search/?utm_campaign=twitter-free&utm_source=support&utm_medium=search',
153 'system_info' => $this->get_system_info(),
154 'system_info_n' => str_replace("</br>", "\n", $this->get_system_info()),
155 'feeds' => $feeds,
156 'supportUrl' => $this->get_support_url(),
157 'svgIcons' => CTF_Feed_Builder::builder_svg_icons(),
158 'socialWallLinks' => \TwitterFeed\Builder\CTF_Feed_Builder::get_social_wall_links(),
159 'socialWallActivated' => is_plugin_active( 'social-wall/social-wall.php' ),
160 'genericText' => array(
161 'help' => __( 'Help', 'custom-twitter-feeds' ),
162 'title' => __( 'Support', 'custom-twitter-feeds' ),
163 'gettingStarted' => __( 'Getting Started', 'custom-twitter-feeds' ),
164 'someHelpful' => __( 'Some helpful resources to get you started', 'custom-twitter-feeds' ),
165 'docsN' => __( 'Docs & Troubleshooting', 'custom-twitter-feeds' ),
166 'runInto' => __( 'Run into an issue? Check out our help docs.', 'custom-twitter-feeds' ),
167 'additionalR' => __( 'Additional Resources', 'custom-twitter-feeds' ),
168 'toHelp' => __( 'To help you get the most out of the plugin', 'custom-twitter-feeds' ),
169 'needMore' => __( 'Need more support? We’re here to help.', 'custom-twitter-feeds' ),
170 'ourFast' => __( 'Our fast and friendly support team is always happy to help!', 'custom-twitter-feeds' ),
171 'systemInfo' => __( 'System Info', 'custom-twitter-feeds' ),
172 'exportSettings' => __( 'Export Settings', 'custom-twitter-feeds' ),
173 'shareYour' => __( 'Share your plugin settings easily with Support', 'custom-twitter-feeds' ),
174 'copiedToClipboard' => __( 'Copied to clipboard', 'custom-twitter-feeds' ),
175 ),
176 'buttons' => array(
177 'searchDoc' => __( 'Search Documentation', 'custom-twitter-feeds' ),
178 'moreHelp' => __( 'More help on Getting started', 'custom-twitter-feeds' ),
179 'viewDoc' => __( 'View Documentation', 'custom-twitter-feeds' ),
180 'viewBlog' => __( 'View Blog', 'custom-twitter-feeds' ),
181 'submitTicket' => __( 'Submit a Support Ticket', 'custom-twitter-feeds' ),
182 'copy' => __( 'Copy', 'custom-twitter-feeds' ),
183 'copied' => __( 'Copied', 'custom-twitter-feeds' ),
184 'copy' => __( 'Copy', 'custom-twitter-feeds' ),
185 'export' => __( 'Export', 'custom-twitter-feeds' ),
186 'expand' => __( 'Expand', 'custom-twitter-feeds' ),
187 'collapse' => __( 'Collapse', 'custom-twitter-feeds' ),
188 ),
189 'icons' => array(
190 'rocket' => CTF_PLUGIN_URL . 'admin/assets/img/rocket-icon.png',
191 'book' => CTF_PLUGIN_URL . 'admin/assets/img/book-icon.png',
192 'save' => CTF_PLUGIN_URL . 'admin/assets/img/save-plus-icon.png',
193 'magnify' => '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.91667 0.5C7.35326 0.5 8.73101 1.07068 9.74683 2.08651C10.7627 3.10233 11.3333 4.48008 11.3333 5.91667C11.3333 7.25833 10.8417 8.49167 10.0333 9.44167L10.2583 9.66667H10.9167L15.0833 13.8333L13.8333 15.0833L9.66667 10.9167V10.2583L9.44167 10.0333C8.45879 10.8723 7.20892 11.3333 5.91667 11.3333C4.48008 11.3333 3.10233 10.7627 2.08651 9.74683C1.07068 8.73101 0.5 7.35326 0.5 5.91667C0.5 4.48008 1.07068 3.10233 2.08651 2.08651C3.10233 1.07068 4.48008 0.5 5.91667 0.5ZM5.91667 2.16667C3.83333 2.16667 2.16667 3.83333 2.16667 5.91667C2.16667 8 3.83333 9.66667 5.91667 9.66667C8 9.66667 9.66667 8 9.66667 5.91667C9.66667 3.83333 8 2.16667 5.91667 2.16667Z" fill="#141B38"/></svg>',
194 'rightAngle' => '<svg width="7" height="11" viewBox="0 0 5 8" fill="#000" xmlns="http://www.w3.org/2000/svg"><path d="M1.00006 0L0.0600586 0.94L3.11339 4L0.0600586 7.06L1.00006 8L5.00006 4L1.00006 0Z" fill="#000"/></svg>',
195 'linkIcon' => '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.166626 10.6583L8.99163 1.83329H3.49996V0.166626H11.8333V8.49996H10.1666V3.00829L1.34163 11.8333L0.166626 10.6583Z" fill="#141B38"/></svg>',
196 'plusIcon' => '<svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.0832 6.83317H7.08317V11.8332H5.4165V6.83317H0.416504V5.1665H5.4165V0.166504H7.08317V5.1665H12.0832V6.83317Z" fill="white"/></>',
197 'loaderSVG' => '<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve"><path fill="#fff" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/></path></svg>',
198 'checkmarkSVG' => '<svg width="13" height="10" viewBox="0 0 13 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.13112 6.88917L11.4951 0.525204L12.9093 1.93942L5.13112 9.71759L0.888482 5.47495L2.3027 4.06074L5.13112 6.88917Z" fill="#8C8F9A"/></svg>',
199 'forum' => '<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.8335 14V3.50004C19.8335 3.19062 19.7106 2.89388 19.4918 2.67508C19.273 2.45629 18.9762 2.33337 18.6668 2.33337H3.50016C3.19074 2.33337 2.894 2.45629 2.6752 2.67508C2.45641 2.89388 2.3335 3.19062 2.3335 3.50004V19.8334L7.00016 15.1667H18.6668C18.9762 15.1667 19.273 15.0438 19.4918 14.825C19.7106 14.6062 19.8335 14.3095 19.8335 14ZM24.5002 7.00004H22.1668V17.5H7.00016V19.8334C7.00016 20.1428 7.12308 20.4395 7.34187 20.6583C7.56066 20.8771 7.85741 21 8.16683 21H21.0002L25.6668 25.6667V8.16671C25.6668 7.85729 25.5439 7.56054 25.3251 7.34175C25.1063 7.12296 24.8096 7.00004 24.5002 7.00004Z" fill="#141B38"/></svg>',
200 'copy' => '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 1.33334H6C5.26667 1.33334 4.66667 1.93334 4.66667 2.66667V10.6667C4.66667 11.4 5.26667 12 6 12H12C12.7333 12 13.3333 11.4 13.3333 10.6667V2.66667C13.3333 1.93334 12.7333 1.33334 12 1.33334ZM12 10.6667H6V2.66667H12V10.6667ZM2 10V8.66667H3.33333V10H2ZM2 6.33334H3.33333V7.66667H2V6.33334ZM6.66667 13.3333H8V14.6667H6.66667V13.3333ZM2 12.3333V11H3.33333V12.3333H2ZM3.33333 14.6667C2.6 14.6667 2 14.0667 2 13.3333H3.33333V14.6667ZM5.66667 14.6667H4.33333V13.3333H5.66667V14.6667ZM9 14.6667V13.3333H10.3333C10.3333 14.0667 9.73333 14.6667 9 14.6667ZM3.33333 4V5.33334H2C2 4.6 2.6 4 3.33333 4Z" fill="#141B38"/></svg>',
201 'downAngle' => '<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.94 0.226685L4 3.28002L7.06 0.226685L8 1.16668L4 5.16668L0 1.16668L0.94 0.226685Z" fill="#141B38"/></svg>',
202 'exportSVG' => '<svg class="btn-icon" width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.166748 14.6667H11.8334V13H0.166748V14.6667ZM11.8334 5.5H8.50008V0.5H3.50008V5.5H0.166748L6.00008 11.3333L11.8334 5.5Z" fill="#141B38"/></svg>',
203 ),
204 'images' => array(
205 'supportMembers' => CTF_PLUGIN_URL . 'admin/assets/img/support-members.png'
206 ),
207 'articles' => array(
208 'gettingStarted' => array(
209 array(
210 'title' => __( 'Creating Your First Twitter Feed', 'custom-twitter-feeds' ),
211 'link' => 'https://smashballoon.com/doc/setting-up-the-free-custom-twitter-feeds-wordpress-plugin/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=Creating your first Twitter feed'
212 ),
213 array(
214 'title' => __( 'What are the Differences Between the Free and Pro Versions', 'custom-twitter-feeds' ),
215 'link' => 'https://smashballoon.com/doc/differences-between-the-free-version-and-pro-version-of-the-custom-twitter-feeds-plugin/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=What are the Differences Between the Free and Pro Versions'
216 ),
217 array(
218 'title' => __( 'I Just Upgraded to Pro but Can\'t Use the New Features', 'custom-twitter-feeds' ),
219 'link' => 'https://smashballoon.com/doc/just-upgraded-pro-cant-use-new-features/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=I Just Upgraded to Pro but Cant Use the New Features'
220 ),
221 ),
222 'docs' => array(
223 array(
224 'title' => __( 'Guide to GDPR Compliance', 'custom-twitter-feeds' ),
225 'link' => 'https://smashballoon.com/doc/custom-twitter-feeds-gdpr-compliance/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=Guide to GDPR Compliance'
226 ),
227 array(
228 'title' => __( 'How to Resolve Error Messages', 'custom-twitter-feeds' ),
229 'link' => 'https://smashballoon.com/doc/twitter-api-error-message-reference/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=How to Resolve Error Messages'
230 ),
231 array(
232 'title' => __( 'My Feed Stopped Updating', 'custom-twitter-feeds' ),
233 'link' => 'https://smashballoon.com/my-feed-wont-show-the-latest-tweets/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=My Feed Stopped Updating'
234 ),
235 ),
236 'resources' => array(
237 array(
238 'title' => __( 'How to Create a Twitter Developer App', 'custom-twitter-feeds' ),
239 'link' => 'https://smashballoon.com/doc/create-your-own-twitter-app/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=How to Create a Twitter Developer App'
240 ),
241 array(
242 'title' => __( 'Is the Content of My Feed Crawlable by Search Engines?', 'custom-twitter-feeds' ),
243 'link' => 'https://smashballoon.com/doc/is-the-content-of-my-feed-crawlable-by-search-engines-and-how-does-it-help-improve-my-seo-2/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=Is the Content of My Feed Crawlable by Search Engines'
244 ),
245 array(
246 'title' => __( 'How do I Embed My Feed Directly in a Template?', 'custom-twitter-feeds' ),
247 'link' => 'https://smashballoon.com/doc/how-do-i-embed-the-twitter-feed-directly-into-a-theme-template/?twitter&utm_campaign=twitter-free&utm_source=support&utm_medium=docs&utm_content=How do I Embed My Feed Directly in a Template'
248 ),
249 ),
250 )
251 );
252
253 return $return;
254 }
255
256 /**
257 * Get System Info
258 *
259 * @since 2.0
260 */
261 public function get_system_info() {
262 $output = '';
263
264 // Build the output strings
265 $output .= self::get_site_n_server_info();
266 $output .= self::get_active_plugins_info();
267 $output .= self::get_global_settings_info();
268 $output .= self::get_feeds_settings_info();
269 $output .= self::get_api_info();
270 $output .= self::get_cron_report();
271 $output .= self::get_image_resizing_info();
272 $output .= self::get_posts_table_info();
273 $output .= self::get_errors_info();
274
275 return $output;
276 }
277
278 /**
279 * Get Site and Server Info
280 *
281 * @since 2.0
282 *
283 * @return string
284 */
285 public static function get_site_n_server_info() {
286 $allow_url_fopen = ini_get( 'allow_url_fopen' ) ? "Yes" : "No";
287 $php_curl = is_callable('curl_init') ? "Yes" : "No";
288 $php_json_decode = function_exists("json_decode") ? "Yes" : "No";
289 $php_ssl = in_array('https', stream_get_wrappers()) ? "Yes" : "No";
290
291 $output = '## SITE/SERVER INFO: ##' . "</br>";
292 $output .= 'Plugin Version:' . self::get_whitespace( 11 ) . CTF_PLUGIN_NAME . "</br>";
293 $output .= 'Site URL:' . self::get_whitespace( 17 ) . site_url() . "</br>";
294 $output .= 'Home URL:' . self::get_whitespace( 17 ) . home_url() . "</br>";
295 $output .= 'WordPress Version:' . self::get_whitespace( 8 ) . get_bloginfo( 'version' ) . "</br>";
296 $output .= 'PHP Version:' . self::get_whitespace( 14 ) . PHP_VERSION . "</br>";
297 $output .= 'Web Server Info:' . self::get_whitespace( 10 ) . $_SERVER['SERVER_SOFTWARE'] . "</br>";
298 $output .= 'PHP allow_url_fopen:' . self::get_whitespace( 6 ) . $allow_url_fopen . "</br>";
299 $output .= 'PHP cURL:' . self::get_whitespace( 17 ) . $php_curl . "</br>";
300 $output .= 'JSON:' . self::get_whitespace( 21 ) . $php_json_decode . "</br>";
301 $output .= 'SSL Stream:' . self::get_whitespace( 15 ) . $php_ssl . "</br>";
302 $output .= "</br>";
303
304 return $output;
305 }
306
307 /**
308 * Get Active Plugins
309 *
310 * @since 2.0
311 *
312 * @return string
313 */
314 public static function get_active_plugins_info() {
315 $plugins = get_plugins();
316 $active_plugins = get_option('active_plugins');
317 $output = "## ACTIVE PLUGINS: ## </br>";
318
319 foreach ( $plugins as $plugin_path => $plugin ) {
320 if ( in_array( $plugin_path, $active_plugins ) ) {
321 $output .= $plugin['Name'] . ': ' . $plugin['Version'] ."</br>";
322 }
323 }
324
325 $output .= "</br>";
326
327 return $output;
328 }
329
330 /**
331 * Get Global Settings
332 *
333 * @since 2.0
334 *
335 * @return string
336 */
337 public static function get_global_settings_info() {
338 $output = "## GLOBAL SETTINGS: ## </br>";
339 $ctf_settings = get_option( 'ctf_options', array() );
340 $usage_tracking = get_option( 'ctf_usage_tracking', array( 'last_send' => 0, 'enabled' => \ctf_is_pro_version() ) );
341
342 //$output .= "</br>";
343 //$output .= 'Caching: ';
344 if ( wp_next_scheduled( 'ctf_feed_update' ) ) {
345 $time_format = get_option( 'time_format' );
346 if ( ! $time_format ) {
347 $time_format = 'g:i a';
348 }
349 //
350 $schedule = wp_get_schedule( 'ctf_feed_update' );
351 if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', 'custom-twitter-feeds' );
352 if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', 'custom-twitter-feeds' );
353 $ctf_next_cron_event = wp_next_scheduled( 'ctf_feed_update' );
354 //$output = __( 'Next check', 'custom-twitter-feeds' ) . ': ' . date( $time_format, $ctf_next_cron_event + ctf_get_utc_offset() ) . ' (' . $schedule . ')';
355
356 } else {
357 //$output .= 'Nothing currently scheduled';
358 }
359 $output .= "</br>";
360 $output .= 'Site Key: ';
361 $output .= isset( $ctf_settings[ CTF_SITE_ACCESS_TOKEN_KEY ] ) ? $ctf_settings[ CTF_SITE_ACCESS_TOKEN_KEY ] : 'NO KEY!';
362 $output .= "</br>";
363 $output .= 'GDPR: ';
364 $output .= isset( $ctf_settings[ 'gdpr' ] ) ? $ctf_settings[ 'gdpr' ] : ' Not setup';
365 $output .= "</br>";
366 $output .= 'Custom CSS: ';
367 $output .= isset( $ctf_settings['sb_instagram_custom_css'] ) && ! empty( $ctf_settings['sb_instagram_custom_css'] ) ? $ctf_settings['sb_instagram_custom_css'] : 'Empty';
368 $output .= "</br>";
369 $output .= 'Custom JS: ';
370 $output .= isset( $ctf_settings['sb_instagram_custom_js'] ) && ! empty( $ctf_settings['sb_instagram_custom_js'] ) ? $ctf_settings['sb_instagram_custom_js'] : 'Empty';
371 $output .= "</br>";
372 $output .= 'Optimize Images: ';
373 $output .= isset( $ctf_settings[ 'sb_instagram_disable_resize' ] ) && $ctf_settings[ 'sb_instagram_disable_resize' ] == 'on' ? 'Enabled' : 'Disabled';
374 $output .= "</br>";
375 $output .= 'Usage Tracking: ';
376 $output .= isset( $usage_tracking['enabled'] ) && $usage_tracking['enabled'] == true ? 'Enabled' : 'Disabled';
377 $output .= "</br>";
378 $output .= 'AJAX theme loading fix: ';
379 $output .= isset( $ctf_settings[ 'ctf_ajax' ] ) && $ctf_settings[ 'ctf_ajax' ] == true ? 'Enabled' : 'Disabled';
380 $output .= "</br>";
381 $output .= 'AJAX Initial: ';
382 $output .= isset( $ctf_settings['ctf_ajax_initial'] ) && $ctf_settings['ctf_ajax_initial'] == true ? 'Enabled' : 'Disabled';
383 $output .= "</br>";
384 $output .= 'Enqueue in Head: ';
385 $output .= isset( $ctf_settings['ctf_enqueue_js_in_head'] ) && $ctf_settings['ctf_enqueue_js_in_head'] == true ? 'Enabled' : 'Disabled';
386 $output .= "</br>";
387 $output .= 'Enqueue in Shortcode: ';
388 $output .= isset( $ctf_settings['ctf_enqueue_css_in_shortcode'] ) && $ctf_settings['ctf_enqueue_css_in_shortcode'] == true ? 'Enabled' : 'Disabled';
389 $output .= "</br>";
390 $output .= 'Enable JS Image: ';
391 $output .= isset( $ctf_settings['ctf_enable_js_image_loading'] ) && $ctf_settings['ctf_enable_js_image_loading'] == true ? 'Enabled' : 'Disabled';
392 $output .= "</br>";
393 $output .= 'Admin Error Notice: ';
394 $output .= isset( $ctf_settings['disable_admin_notice'] ) && $ctf_settings['disable_admin_notice'] == true ? 'Enabled' : 'Disabled';
395 $output .= "</br>";
396 $output .= 'Feed Issue Email Reports: ';
397 $output .= isset( $ctf_settings['enable_email_report'] ) && $ctf_settings['enable_email_report'] == true ? 'Enabled' : 'Disabled';
398 $output .= "</br>";
399 $output .= 'Email notification: ';
400 $output .= isset( $ctf_settings['email_notification'] ) && $ctf_settings['email_notification'] !== null ? ucfirst($ctf_settings['email_notification']) : 'Off';
401 $output .= "</br>";
402 $output .= 'Email notification addresses: ';
403 $output .= isset( $ctf_settings['email_notification_addresses'] ) && !empty( $ctf_settings['email_notification_addresses'] ) ? $ctf_settings['email_notification_addresses'] : 'Not available';
404 $output .= "</br>";
405 $output .= "</br>";
406 return $output;
407 }
408
409 /**
410 * Get Feeds Settings
411 *
412 * @since 2.0
413 *
414 * @return string
415 */
416 public static function get_feeds_settings_info() {
417 $output = "## FEEDS: ## </br>";
418
419 $feeds_list = CTF_Feed_Builder::get_feed_list();
420 $i = 0;
421 foreach( $feeds_list as $feed ) {
422
423 $type = ! empty( $feed['settings']->type ) ? $feed['settings']->type : 'user';
424 if ( $i >= 25 ) {
425 break;
426 }
427 $output .= $feed['feed_name'];
428 if ( isset( $feed['settings'] ) ) {
429 $source = array();
430 $output .= ' - ' . ucfirst( $type );
431 $output .= '</br>';
432
433 }
434 $output .= "</br>";
435 if ( isset( $feed['location_summary'] ) && count( $feed['location_summary'] ) > 0 ) {
436 $first_feed = $feed['location_summary'][0];
437 $output .= $first_feed['link'] . '?sb_debug';
438 }
439 $output .= "</br>";
440
441 $i++;
442 }
443 $output .= "</br>";
444
445 return $output;
446 }
447
448 /**
449 * Get API Response Info
450 *
451 * @since 2.0
452 *
453 * @return string
454 */
455 public static function get_api_info() {
456 $options = get_option( 'ctf_options' );
457
458 $access_token = isset( $options['access_token'] ) ? $options['access_token'] : '';
459 $access_token_secret = isset( $options['access_token_secret'] ) ? $options['access_token_secret'] : '';
460
461 $output = '';
462 if (isset($options['request_method'])
463 && ! empty($access_token)
464 && !empty($options['consumer_key'])
465 && !empty($options['consumer_secret'])&&
466 !empty($options['have_own_tokens'])
467 ) {
468
469 $consumer_key = $options['consumer_key'];
470 $consumer_secret = $options['consumer_secret'];
471
472 $request_settings = array(
473 'consumer_key' => $consumer_key,
474 'consumer_secret' => $consumer_secret,
475 'access_token' => $access_token,
476 'access_token_secret' => $access_token_secret
477 );
478
479 $request_method = isset( $options['request_method'] ) ? $options['request_method'] : 'auto';
480
481 $twitter_api = new \TwitterFeed\V2\CtfOauthConnect( $request_settings, 'usertimeline' );
482 $twitter_api->setUrlBase();
483 $get_fields = array( 'count' => '1' );
484 $twitter_api->setGetFields( $get_fields );
485 $twitter_api->setRequestMethod( $request_method );
486
487 $twitter_api->performRequest();
488 $response = json_decode( $twitter_api->json, $assoc = true );
489 $screen_name = isset( $response[0] ) ? $response[0]['user']['screen_name'] : 'error';
490 if ( $screen_name === 'error' ) {
491 if ( isset( $response['errors'][0] ) ) {
492 $twitter_api->api_error_no = $response['errors'][0]['code'];
493 $twitter_api->api_error_message = $response['errors'][0]['message'];
494 }
495 }
496
497 $output .= '## Twitter API RESPONSE: ## <br>';
498 if ( ! empty( $twitter_api->api_error_no ) ) {
499 $output .= 'Error No: ' . esc_html( $twitter_api->api_error_no ) . '<br>';
500 $output .= 'Error Message: ' . esc_html( $twitter_api->api_error_message ) . '<br>';
501 } else {
502 $output .= 'Connection was successful! <br>';
503 $output .= 'Account Screen Name: ' . esc_html( $screen_name ) . '<br>';
504 }
505
506 } //End isset check
507
508 $api_call_log = get_option( 'ctf_api_call_log', array() );
509 $output .= '## API CALL LOG: ## </br>';
510 $api_call_log = array_slice( $api_call_log, 0, 10 );
511 foreach ( $api_call_log as $api_call ) {
512 foreach ( $api_call as $key => $value ) {
513 $value = $key === 'time' ? date( 'Y-m-d H:i:s', $value ) : $value;
514 $output .= $key . ': ' . $value . "</br>";
515 }
516 $output .= '</br></br>';
517 }
518 $output .= '</br>';
519
520 $output .= '## UPDATE NOTES: ## </br>';
521
522
523 $ctf_statuses_option = get_option( 'ctf_statuses', array() );
524 if ( ! empty( $ctf_statuses_option['first_cron_update'] ) ) {
525 $output .= 'First Cron Update: '. date( 'Y-m-d H:i:s', $ctf_statuses_option['first_cron_update'] ) .' ' . ($ctf_statuses_option['first_cron_update'] - time()) / HOUR_IN_SECONDS . ' hours';
526 $output .= "</br>";
527 }
528 if ( ! empty($ctf_statuses_option['smash_twitter_cron']['last_update_process_time']) ) {
529 $output .= 'Last Update: '. date( 'Y-m-d H:i:s', $ctf_statuses_option['smash_twitter_cron']['last_update_process_time'] ) . '';
530 }
531
532
533 $output .= "</br></br>";
534
535 return $output;
536 }
537
538 /**
539 * Get Reports
540 *
541 * @since 6.0
542 *
543 * @return string
544 */
545 public static function get_cron_report() {
546 $output = '## Cron Cache Report: ## </br>';
547 $cron_report = get_option( 'ctf_cron_report', array() );
548 if ( ! empty( $cron_report ) ) {
549 $output .= 'Time Ran: ' . esc_html( $cron_report['notes']['time_ran'] );
550 $output .= '</br>';
551 $output .= 'Found Feeds: ' . esc_html( $cron_report['notes']['num_found_transients'] );
552 $output .= '</br>';
553 $output .= '</br>';
554
555 foreach ( $cron_report as $key => $value ) {
556 if ( $key !== 'notes' ) {
557 $output .= esc_html( $key ) . ':';
558 $output .= '</br>';
559 if ( ! empty( $value['last_retrieve'] ) ) {
560 $output .= 'Last Retrieve: ' . esc_html( $value['last_retrieve'] );
561 $output .= '</br>';
562 }
563 if ( ! empty( $value['did_update'] ) ) {
564 $output .= 'Did Update: ' . esc_html( $value['did_update'] );
565 }
566 $output .= '</br>';
567 $output .= '</br>';
568 }
569 }
570 } else {
571 $output .= 'No Cron Report </br></br>';
572 }
573
574 $cron = _get_cron_array();
575 foreach ( $cron as $key => $data ) {
576 $is_target = false;
577 foreach ( $data as $key2 => $val ) {
578 if ( strpos( $key2, 'ctf' ) !== false || strpos( $key2, 'twitter' ) !== false ) {
579 $is_target = true;
580 $output .= esc_html( $key2 );
581 $output .= '</br>';
582 }
583 }
584 if ( $is_target ) {
585 $output .= esc_html( date( 'Y-m-d H:i:s', $key ) );
586 $output .= '</br>';
587 $output .= esc_html( 'Next Scheduled: ' . round( ( (int) $key - time() ) / 60 ) . ' minutes' );
588 $output .= '</br>';
589 $output .= '</br>';
590 }
591 }
592
593 return $output;
594 }
595
596 /**
597 * Get Image Resizing Info
598 *
599 * @since 2.0
600 *
601 * @return string
602 */
603 public static function get_image_resizing_info() {
604
605 return '';
606 }
607
608 /**
609 * Get Posts Table Info
610 *
611 * @since 2.0
612 *
613 * @return string
614 */
615 public static function get_posts_table_info() {
616 return '';
617 $output = "## POSTS: ## </br>";
618
619 global $wpdb;
620 $table_name = esc_sql( $wpdb->prefix . CTF_POSTS_TABLE );
621 $feeds_posts_table_name = esc_sql( $wpdb->prefix . CTF_FEEDS_POSTS_TABLE );
622
623 if ( $wpdb->get_var( "show tables like '$feeds_posts_table_name'" ) != $feeds_posts_table_name ) {
624 $output .= 'no feeds posts table' . "</br>";
625 } else {
626 $last_result = $wpdb->get_results( "SELECT * FROM $feeds_posts_table_name ORDER BY id DESC LIMIT 1;" );
627 if ( is_array( $last_result ) && isset( $last_result[0] ) ) {
628 $output .= '## FEEDS POSTS TABLE ##' . "</br>";
629 foreach ( $last_result as $column ) {
630 foreach ( $column as $key => $value ) {
631 $output .= $key . ': ' . esc_html( $value ) . "</br>";;
632 }
633 }
634 } else {
635 $output .= 'feeds posts has no rows';
636 $output .= "</br>";
637 }
638 }
639 $output .= "</br>";
640 if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) {
641 $output .= 'no posts table' . "</br>";
642 } else {
643 $last_result = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY id DESC LIMIT 1;" );
644 if ( is_array( $last_result ) && isset( $last_result[0] ) ) {
645 $output .= '## POSTS TABLE ##';
646 $output .= "</br>";
647 foreach ( $last_result as $column ) {
648 foreach ( $column as $key => $value ) {
649 $output .= $key . ': ' . esc_html( $value ) . "</br>";;
650 }
651 }
652 } else {
653 $output .= 'posts has no rows' . "</br>";
654 }
655 }
656 $output .= "</br>";
657
658 return $output;
659 }
660
661 /**
662 * SBI Get Errors Info
663 *
664 * @since 2.0
665 *
666 * @return string
667 */
668 public static function get_errors_info() {
669 $errors = get_option( 'ctf_errors', array() );
670 $output = "## ERRORS: ##" . "</br>";
671 if ( ! CTF_DOING_SMASH_TWITTER ) {
672 if ( ! empty( $errors ) ) {
673 foreach ( $errors as $error ) {
674 $output .= esc_html( $error ) . "</br>";
675 }
676 } else {
677 $output .= "No Error Information Stored</br>";
678 }
679 } else {
680 $ctf_statuses_option = get_option( 'ctf_statuses', array() );
681 if ( ! empty( $ctf_statuses_option['smash_twitter']['error_log'] ) ) {
682 $reversed = array_reverse( $ctf_statuses_option['smash_twitter']['error_log'] );
683 foreach ( $reversed as $error ) :
684 $output .= $error . "</br>";
685 endforeach;
686 }
687 }
688
689
690 return $output;
691 }
692
693 /**
694 * Get Action Logs Info
695 *
696 * @since 2.0
697 *
698 * @return string
699 */
700 public static function get_action_logs_info() {
701 $output = "## ACTION LOG ##" . "</br>";
702 global $sb_instagram_posts_manager;
703
704 $actions = $sb_instagram_posts_manager->get_action_log();
705 if ( ! empty( $actions ) ) :
706 foreach ( $actions as $action ) :
707 $output .= strip_tags($action) . "</br>";
708 endforeach;
709 endif;
710 $output .= "</br>";
711
712 return $output;
713 }
714
715
716
717 /**
718 * SBI Get Support URL
719 *
720 * @since 2.0
721 *
722 * @return string $url
723 */
724 public function get_support_url() {
725 $url = 'https://smashballoon.com/custom-twitter-feeds/support/?utm_campaign=twitter-free&utm_source=support&utm_medium=support';
726 $license_type = ctf_is_pro_version() ? 'pro' : 'free';
727
728 $args = array();
729 $license_key = false;
730 if ( $license_key ) {
731 $license_key = ctf_encrypt_decrypt( 'encrypt', $license_key );
732 $args['license'] = $license_key;
733 }
734
735 $args['license_type'] = $license_type;
736 $args['version'] = CTF_VERSION;
737 $url = add_query_arg( $args, $url );
738 return $url;
739 }
740
741 /**
742 * SBI Export Feed Settings JSON
743 *
744 * @since 2.0
745 *
746 * @return CTF_Response
747 */
748 public function ctf_export_settings_json() {
749 \TwitterFeed\Builder\CTF_Feed_Builder::check_privilege();
750
751 if ( ! isset( $_GET['feed_id'] ) ) {
752 return;
753 }
754 $feed_id = filter_var( $_GET['feed_id'], FILTER_SANITIZE_NUMBER_INT );
755 $feed = CTF_Feed_Saver_Manager::get_export_json( $feed_id );
756 $feed_info = CTF_Db::feeds_query( array('id' => $feed_id) );
757 $feed_name = strtolower( $feed_info[0]['feed_name'] );
758 $filename = 'ctf-feed-' . $feed_name . '.json';
759 // Creates a new csv file and store it in tmp directory
760 $file = fopen( '/tmp/' . $filename, 'w' );
761 fwrite($file, $feed);
762 fclose($file);
763 // output headers so that the file is downloaded rather than displayed
764 header( "Content-type: application/json" );
765 header( "Content-disposition: attachment; filename = " . $filename );
766 readfile( "/tmp/" . $filename );
767 exit;
768 }
769
770 /**
771 * SBI Get Whitespace
772 *
773 * @since 2.0
774 *
775 * @param int $times
776 *
777 * @return string
778 */
779 public static function get_whitespace( $times ) {
780 return str_repeat('&nbsp;', $times );
781 }
782
783 /**
784 * Extensions Manager Page View Template
785 *
786 * @since 2.0
787 */
788 public function support_page(){
789 return CTF_View::render( 'support.index' );
790 }
791 }
792