Admin
1 month ago
Builder
1 month ago
Integrations
1 month ago
SmashTwitter
1 month ago
UsageTracking
1 month ago
V2
1 month ago
blocks
1 month ago
CTF_Display_Elements.php
1 month ago
CTF_Feed.php
1 month ago
CTF_Feed_Locator.php
1 month ago
CTF_GDPR_Integrations.php
1 month ago
CTF_Parse.php
1 month ago
CTF_Settings.php
1 month ago
CtfAdmin.php
1 month ago
CtfCache.php
1 month ago
CtfFeed.php
1 month ago
CtfOauthConnect.php
1 month ago
SB_Twitter_Cron_Updater.php
1 month ago
admin-hooks.php
1 month ago
ctf-functions.php
1 month ago
notices.php
1 month ago
widget.php
1 month ago
CtfAdmin.php
167 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class CtfAdmin |
| 4 | * |
| 5 | * Uses the Settings API to create easily customizable settings pages and tabs |
| 6 | */ |
| 7 | use TwitterFeed\CTF_GDPR_Integrations; |
| 8 | use TwitterFeed\CTF_Feed_Locator; |
| 9 | use TwitterFeed\Admin\CTF_Notifications; |
| 10 | |
| 11 | |
| 12 | // Don't load directly |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | die( '-1' ); |
| 15 | } |
| 16 | |
| 17 | class CtfAdmin |
| 18 | { |
| 19 | public function __construct() |
| 20 | { |
| 21 | add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
| 22 | add_action( 'admin_init', array( $this, 'ctf_current_user_can' ) ); |
| 23 | } |
| 24 | |
| 25 | public function ctf_current_user_can( $cap ) { |
| 26 | return ctf_current_user_can( $cap ); |
| 27 | } |
| 28 | |
| 29 | public function add_menu() |
| 30 | { |
| 31 | $cap = ctf_get_manage_options_cap(); |
| 32 | $data_x_icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMjEuMTE2MSA2LjI3MzQ0SDI0LjIyODlMMTcuNDI4NCAxNC4wNDU5TDI1LjQyODYgMjQuNjIyNUgxOS4xNjQ1TDE0LjI1ODMgMTguMjA3OUw4LjY0NDQgMjQuNjIyNUg1LjUyOTc2TDEyLjgwMzUgMTYuMzA5TDUuMTI4OTEgNi4yNzM0NEgxMS41NTJMMTUuOTg2OCAxMi4xMzY3TDIxLjExNjEgNi4yNzM0NFpNMjAuMDIzNiAyMi43NTk0SDIxLjc0ODRMMTAuNjE0OCA4LjAzODcxSDguNzYzOUwyMC4wMjM2IDIyLjc1OTRaIiBmaWxsPSJibGFjayIvPjwvc3ZnPg=='; |
| 33 | |
| 34 | $notice = ''; |
| 35 | |
| 36 | $ctf_notifications = new CTF_Notifications(); |
| 37 | $notifications = $ctf_notifications->get(); |
| 38 | |
| 39 | $notice_bubble = ''; |
| 40 | if ( empty( $notice ) && ! empty( $notifications ) && is_array( $notifications ) ) { |
| 41 | $notice_bubble = ' <span class="ctf-notice-alert"><span>'.count( $notifications ).'</span></span>'; |
| 42 | } |
| 43 | |
| 44 | add_menu_page( |
| 45 | __( 'Twitter Feeds', 'custom-twitter-feeds' ), |
| 46 | __( 'Twitter Feeds', 'custom-twitter-feeds' ). $notice_bubble . $notice, |
| 47 | $cap, |
| 48 | 'custom-twitter-feeds', |
| 49 | 'sb_twitter_settings_page', |
| 50 | ctf_should_rebrand_to_x() ? $data_x_icon : 'dashicons-twitter' |
| 51 | ); |
| 52 | |
| 53 | add_submenu_page( |
| 54 | 'custom-twitter-feeds', |
| 55 | __( 'Upgrade to Pro', 'custom-twitter-feeds' ), |
| 56 | __( '<span class="ctf_get_pro">Upgrade to Pro</span>', 'custom-twitter-feeds' ), |
| 57 | $cap, |
| 58 | 'https://smashballoon.com/custom-twitter-feeds/twitter-lite-upgrade/?utm_campaign=twitter-free&utm_source=menu-link&utm_medium=upgrade-link', |
| 59 | '' |
| 60 | ); |
| 61 | |
| 62 | //Show a Instagram plugin menu item if it isn't already installed |
| 63 | if( !is_plugin_active( 'instagram-feed/instagram-feed.php' ) && !is_plugin_active( 'instagram-feed-pro/instagram-feed.php' ) ){ |
| 64 | add_submenu_page( |
| 65 | 'custom-twitter-feeds', |
| 66 | __( 'Instagram Feed', 'custom-twitter-feeds' ), |
| 67 | '<span class="ctf_get_sbi">' . __( 'Instagram Feed', 'custom-twitter-feeds' ) . '</span>', |
| 68 | 'manage_options', |
| 69 | 'admin.php?page=custom-twitter-feeds&tab=more', |
| 70 | '' |
| 71 | ); |
| 72 | } |
| 73 | |
| 74 | //Show a Instagram plugin menu item if it isn't already installed |
| 75 | if( !is_plugin_active( 'custom-facebook-feed/custom-facebook-feed.php' ) && !is_plugin_active( 'custom-facebook-feed-pro/custom-facebook-feed.php' ) ){ |
| 76 | add_submenu_page( |
| 77 | 'custom-twitter-feeds', |
| 78 | __( 'Facebook Feed', 'custom-twitter-feeds' ), |
| 79 | '<span class="ctf_get_cff">' . __( 'Facebook Feed', 'custom-twitter-feeds' ) . '</span>', |
| 80 | 'manage_options', |
| 81 | 'admin.php?page=custom-twitter-feeds&tab=more', |
| 82 | '' |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | //Show a YouTube plugin menu item if it isn't already installed |
| 87 | if( !is_plugin_active( 'feeds-for-youtube/youtube-feed.php' ) && !is_plugin_active( 'youtube-feed-pro/youtube-feed.php' ) ){ |
| 88 | add_submenu_page( |
| 89 | 'custom-twitter-feeds', |
| 90 | __( 'YouTube Feed', 'custom-twitter-feeds' ), |
| 91 | '<span class="ctf_get_yt">' . __( 'YouTube Feed', 'custom-twitter-feeds' ) . '</span>', |
| 92 | 'manage_options', |
| 93 | 'admin.php?page=custom-twitter-feeds&tab=more', |
| 94 | '' |
| 95 | ); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | |
| 100 | public static function get_active_tab( $tab = '' ) |
| 101 | { |
| 102 | return 'configure'; |
| 103 | } |
| 104 | |
| 105 | public function access_token_button() |
| 106 | { |
| 107 | $this->the_admin_access_token_configure_html( $_GET ); |
| 108 | $options = get_option( 'ctf_options' ); |
| 109 | $option_checked = ( isset( $options['have_own_tokens'] ) ) ? $options['have_own_tokens'] : false; |
| 110 | ?> |
| 111 | <input name="<?php echo 'ctf_options'.'[have_own_tokens]'; ?>" id="ctf_have_own_tokens" type="checkbox" <?php if ( $option_checked ) echo "checked"; ?> /> |
| 112 | <label for="ctf_have_own_tokens" class="ctf_checkbox"><?php _e( 'Or, manually enter my own Twitter app information' ); ?></label> |
| 113 | <span class="ctf-tooltip-wrap"> |
| 114 | <a class="ctf-tooltip-link" href="JavaScript:void(0);"><i class="fa fa-question-circle" aria-hidden="true"></i></a> |
| 115 | <p class="ctf-tooltip ctf-more-info"><?php _e( 'Check this box if you would like to manually enter the information from your own <a href="https://smashballoon.com/doc/create-your-own-twitter-app/?utm_campaign=twitter-free&utm_source=settings&utm_medium=createownapp" target="_blank">Twitter app</a>', 'custom-twitter-feeds' ); ?>.</p> |
| 116 | </span> |
| 117 | <?php |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * generates the html for the access token retrieving button |
| 122 | * |
| 123 | * @param $access_token_data array the $_GET data if it exists |
| 124 | */ |
| 125 | private function the_admin_access_token_configure_html( $access_token_data ) { |
| 126 | ?> |
| 127 | |
| 128 | <div id="ctf_config"> |
| 129 | |
| 130 | <?php if ( isset( $access_token_data['oauth_token'] ) ) : ?> |
| 131 | <a href="<?php echo OAUTH_PROCESSOR_URL . admin_url( 'admin.php?page=custom-twitter-feeds' ); ?>" id="ctf-get-token"><i class="fa fa-twitter"></i><?php _e( 'Log in to Twitter and get my Access Token and Secret' ); ?></a> |
| 132 | <a class="ctf-tooltip-link" href="https://smashballoon.com/custom-twitter-feeds/token/?utm_campaign=twitter-free&utm_source=settings&utm_medium=buttonnotworking" target="_blank"><?php _e( "Button not working?", 'custom-twitter-feeds' ); ?></a> |
| 133 | |
| 134 | <input type="hidden" id="ctf-retrieved-access-token" value="<?php echo esc_html( sanitize_text_field( $access_token_data['oauth_token'] ) ); ?>"> |
| 135 | <input type="hidden" id="ctf-retrieved-access-token-secret" value="<?php echo esc_html( sanitize_text_field( $access_token_data['oauth_token_secret'] ) ); ?>"> |
| 136 | <input type="hidden" id="ctf-retrieved-default-screen-name" value="<?php echo esc_html( sanitize_text_field( $access_token_data['screen_name'] ) ); ?>"> |
| 137 | |
| 138 | <?php elseif ( isset( $access_token_data['error'] ) && ! isset( $access_token_data['oauth_token'] ) ) : ?> |
| 139 | |
| 140 | <p class="ctf_error_notice"><?php _e( 'There was an error with retrieving your access tokens. Please <a href="https://smashballoon.com/custom-twitter-feeds/token/?utm_campaign=twitter-free&utm_source=settings&utm_medium=errorconnecting" target="_blank">use this tool</a> to get your access token and secret.' ); ?></p><br> |
| 141 | <a href="<?php echo OAUTH_PROCESSOR_URL . admin_url( 'admin.php?page=custom-twitter-feeds' ); ?>" id="ctf-get-token"><i class="fa fa-twitter"></i><?php _e( 'Log in to Twitter and get my Access Token and Secret' ); ?></a> |
| 142 | <a class="ctf-tooltip-link" href="https://smashballoon.com/custom-twitter-feeds/token/?utm_campaign=twitter-free&utm_source=settings&utm_medium=errorconnecting" target="_blank"><?php _e( "Button not working?", 'custom-twitter-feeds' ); ?></a> |
| 143 | |
| 144 | <?php else : ?> |
| 145 | |
| 146 | <a href="<?php echo OAUTH_PROCESSOR_URL . admin_url( 'admin.php?page=custom-twitter-feeds' ); ?>" id="ctf-get-token"><i class="fa fa-twitter"></i><?php _e( 'Log in to Twitter and get my Access Token and Secret' ); ?></a> |
| 147 | <a class="ctf-tooltip-link" href="https://smashballoon.com/custom-twitter-feeds/token/?utm_campaign=twitter-free&utm_source=settings&utm_medium=buttonnotworking" target="_blank"><?php _e( "Button not working?", 'custom-twitter-feeds' ); ?></a> |
| 148 | |
| 149 | <?php endif; ?> |
| 150 | |
| 151 | </div> |
| 152 | <?php |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | function sb_twitter_settings_page() { |
| 157 | $link = admin_url( 'admin.php?page=ctf-settings' ); |
| 158 | ?> |
| 159 | <div id="ctf_admin"> |
| 160 | <div class="ctf_notice"> |
| 161 | <strong><?php esc_html_e( 'The Twitter Feed Settings page has moved!', 'custom-twitter-feeds' ); ?></strong> |
| 162 | <a href="<?php echo esc_url( $link ); ?>"><?php esc_html_e( 'Click here to go to the new page.', 'custom-twitter-feeds' ); ?></a> |
| 163 | </div> |
| 164 | </div> |
| 165 | <?php |
| 166 | } |
| 167 |