Admin
3 weeks ago
Builder
3 weeks ago
Integrations
3 weeks ago
SmashTwitter
3 weeks ago
UsageTracking
3 weeks ago
V2
3 weeks ago
blocks
3 weeks ago
CTF_Display_Elements.php
3 weeks ago
CTF_Feed.php
3 weeks ago
CTF_Feed_Locator.php
3 weeks ago
CTF_GDPR_Integrations.php
3 weeks ago
CTF_Parse.php
3 weeks ago
CTF_Settings.php
3 weeks ago
CtfAdmin.php
3 weeks ago
CtfCache.php
3 weeks ago
CtfFeed.php
3 weeks ago
CtfOauthConnect.php
3 weeks ago
SB_Twitter_Cron_Updater.php
3 weeks ago
admin-hooks.php
3 weeks ago
ctf-functions.php
3 weeks ago
notices.php
3 weeks ago
widget.php
3 weeks ago
admin-hooks.php
435 lines
| 1 | <?php |
| 2 | add_filter( 'ctf_admin_search_label', 'ctf_return_string_hashtag' ); |
| 3 | function ctf_return_string_hashtag( $val ) { |
| 4 | return 'Hashtag:'; |
| 5 | } |
| 6 | |
| 7 | add_filter( 'ctf_admin_search_whatis', 'ctf_return_string_instructions' ); |
| 8 | function ctf_return_string_instructions( $val ) { |
| 9 | return 'Select this option and enter any single hashtag for a hashtag feed. Only tweets made within the last 7 days are available initially. Once a tweet has been retrieved the plugin will keep it in a persistent cache indefinitely'; |
| 10 | } |
| 11 | |
| 12 | add_filter( 'ctf_admin_validate_search_text', 'ctf_validate_search_text', 10, 1 ); |
| 13 | function ctf_validate_search_text( $val ) { |
| 14 | preg_match( "/^[\p{L}0-9_]+|^#+[\p{L}0-9_]+/u", trim( $val ), $hashtags ); |
| 15 | |
| 16 | $hashtags = preg_replace( "/#{2,}/", '', $hashtags ); |
| 17 | |
| 18 | $new_val = ! empty( $hashtags ) ? $new_val = $hashtags[0] : ''; |
| 19 | |
| 20 | if ( substr( $new_val, 0, 1 ) != '#' && $new_val != '' ) { |
| 21 | $new_val = '#' . $new_val; |
| 22 | } |
| 23 | |
| 24 | return $new_val; |
| 25 | } |
| 26 | |
| 27 | add_filter( 'ctf_admin_validate_usertimeline_text', 'ctf_validate_usertimeline_text', 10, 1 ); |
| 28 | function ctf_validate_usertimeline_text( $val ) { |
| 29 | preg_match( "/^[\p{L}0-9_]{1,16}/u" , str_replace( '@', '', trim( $val ) ), $screenname ); |
| 30 | |
| 31 | $new_val = isset( $screenname[0] ) ? $screenname[0] : ''; |
| 32 | |
| 33 | return $new_val; |
| 34 | } |
| 35 | |
| 36 | add_filter( 'ctf_admin_validate_include_replies', 'ctf_validate_include_replies', 10, 1 ); |
| 37 | function ctf_validate_include_replies( $val, $type ) { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | add_filter( 'ctf_admin_set_include_replies', 'ctf_set_include_replies', 10, 1 ); |
| 42 | function ctf_set_include_replies( $new_input ) { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | add_filter( 'ctf_admin_set_include_retweets', 'ctf_set_include_retweets', 10, 1 ); |
| 47 | function ctf_set_include_retweets( $new_input ) { |
| 48 | #if ( version_compare( CTF_VERSION, '2.0', '>=' ) ) { |
| 49 | if ( isset( $new_input ) ) { |
| 50 | if ( isset( $new_input['includeretweets'] ) && ($new_input['includeretweets'] == 'on' || $new_input['includeretweets'] == 'true' )) { |
| 51 | return true; |
| 52 | } else { |
| 53 | return false; |
| 54 | } |
| 55 | } |
| 56 | #}else{ |
| 57 | # if ( isset( $new_input ) && isset( $new_input['type'] ) ) { |
| 58 | # if ( isset( $new_input[$new_input['type'] . '_includeretweets'] ) && $new_input[$new_input['type'] . '_includeretweets'] == 'on' ) { |
| 59 | # return true; |
| 60 | # } else { |
| 61 | # return false; |
| 62 | # } |
| 63 | # } |
| 64 | #} |
| 65 | } |
| 66 | |
| 67 | add_filter( 'ctf_admin_feed_type_list', 'ctf_return_feed_types' ); |
| 68 | function ctf_return_feed_types( $val ) { |
| 69 | return array( 'hometimelineinclude_replies', 'usertimelineinclude_replies' ); |
| 70 | } |
| 71 | |
| 72 | add_action( 'ctf_admin_upgrade_note', 'ctf_update_note' ); |
| 73 | function ctf_update_note() { |
| 74 | ?> |
| 75 | <span class="ctf_note"> - <a href="https://smashballoon.com/custom-twitter-feeds/?utm_campaign=twitter-free&utm_source=settings&utm_medium=proonly" target="_blank">Available in Pro version</a></span> |
| 76 | <?php |
| 77 | } |
| 78 | |
| 79 | add_action( 'ctf_admin_feed_settings_radio_extra', 'ctf_usertimeline_error_message' ); |
| 80 | function ctf_usertimeline_error_message( $args ) |
| 81 | { //sbi_notice sbi_user_id_error |
| 82 | if ( $args['name'] == 'usertimeline') : ?> |
| 83 | <div class="ctf_error_notice ctf_usertimeline_error"> |
| 84 | <?php _e( "<p>Please use a single screenname or Twitter handle of numbers and letters. If you would like to use more than one screen name for your feed, please upgrade to our <a href='https://smashballoon.com/custom-twitter-feeds/?utm_campaign=twitter-free&utm_source=settings&utm_medium=multiuser' target='_blank'>Pro version</a>.</p>" ); ?> |
| 85 | </div> |
| 86 | <?php endif; |
| 87 | } |
| 88 | |
| 89 | add_action( 'ctf_admin_feed_settings_search_extra', 'ctf_hashtag_error_message' ); |
| 90 | function ctf_hashtag_error_message() { |
| 91 | ?> |
| 92 | <div class="ctf_error_notice ctf_search_error"> |
| 93 | <?php _e( "<p>Please use a single hashtag of numbers and letters. If you would like to use more than one hashtag or use search terms for your feed, please upgrade to our <a href='https://smashballoon.com/custom-twitter-feeds/?utm_campaign=twitter-free&utm_source=settings&utm_medium=multisearch' target='_blank'>Pro version</a>.</p>" ); ?> |
| 94 | </div> |
| 95 | <?php |
| 96 | } |
| 97 | |
| 98 | add_filter( 'ctf_admin_customize_quick_links', 'ctf_return_customize_quick_links' ); |
| 99 | function ctf_return_customize_quick_links() { |
| 100 | return array( |
| 101 | 0 => array( 'general', 'General' ), |
| 102 | 1 => array( 'showhide', 'Show/Hide' ), |
| 103 | 2 => array( 'misc', 'Misc' ), |
| 104 | 3 => array( 'advanced', 'Advanced' ) |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | add_filter( 'ctf_admin_style_quick_links', 'ctf_return_style_quick_links' ); |
| 109 | function ctf_return_style_quick_links() { |
| 110 | return array( |
| 111 | 0 => array( 'general', 'General' ), |
| 112 | 1 => array( 'header', 'Header' ), |
| 113 | 2 => array( 'date', 'Date' ), |
| 114 | 3 => array( 'author', 'Author' ), |
| 115 | 4 => array( 'text', 'Tweet Text' ), |
| 116 | 5 => array( 'links', 'Links' ), |
| 117 | 6 => array( 'quoted', 'Retweet Boxes' ), |
| 118 | 7 => array( 'actions', 'Tweet Actions' ), |
| 119 | 8 => array( 'load', 'Load More' ) |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * Pro Options ---------------------------------------- |
| 125 | */ |
| 126 | |
| 127 | add_action( 'ctf_admin_endpoints', 'ctf_add_mentionstimeline_options', 10, 1 ); |
| 128 | function ctf_add_mentionstimeline_options( $admin ) { |
| 129 | $admin->create_settings_field( array( |
| 130 | 'name' => 'search_pro', |
| 131 | 'title' => '<label></label>', // label for the input field |
| 132 | 'callback' => 'feed_settings_radio', // name of the function that outputs the html |
| 133 | 'page' => 'ctf_options_feed_settings', // matches the section name |
| 134 | 'section' => 'ctf_options_feed_settings', // matches the section name |
| 135 | 'option' => 'ctf_options', // matches the options name |
| 136 | 'class' => 'ctf-radio ctf_pro', // class for the wrapper and input field |
| 137 | 'whatis' => 'You can create search feeds which contain a large variety of different terms and operators, such as a combination of #hashtags, @mentions, words, or "phrases"', // what is this? text |
| 138 | 'label' => "Search", |
| 139 | 'has_input' => false, |
| 140 | 'has_replies' => false |
| 141 | )); |
| 142 | $admin->create_settings_field( array( |
| 143 | 'name' => 'mentionstimeline', |
| 144 | 'title' => '<label></label>', // label for the input field |
| 145 | 'callback' => 'feed_settings_radio', // name of the function that outputs the html |
| 146 | 'page' => 'ctf_options_feed_settings', // matches the section name |
| 147 | 'section' => 'ctf_options_feed_settings', // matches the section name |
| 148 | 'option' => 'ctf_options', // matches the options name |
| 149 | 'class' => 'ctf-radio ctf_pro', // class for the wrapper and input field |
| 150 | 'whatis' => 'Select this option to display tweets that @mention your twitter handle', // what is this? text |
| 151 | 'label' => "Mentions", |
| 152 | 'has_input' => false, |
| 153 | 'has_replies' => false |
| 154 | )); |
| 155 | $admin->create_settings_field( array( |
| 156 | 'name' => 'lists', |
| 157 | 'title' => '<label></label>', // label for the input field |
| 158 | 'callback' => 'feed_settings_radio', // name of the function that outputs the html |
| 159 | 'page' => 'ctf_options_feed_settings', // matches the section name |
| 160 | 'section' => 'ctf_options_feed_settings', // matches the section name |
| 161 | 'option' => 'ctf_options', // matches the options name |
| 162 | 'class' => 'ctf-radio ctf_pro', // class for the wrapper and input field |
| 163 | 'whatis' => 'Enter the list ID of the list(s) you want to display. Use this FAQ to create a list on Twitter. Use the helper to find IDs', // what is this? text |
| 164 | 'label' => "Lists", |
| 165 | 'has_input' => false, |
| 166 | 'has_replies' => false |
| 167 | )); |
| 168 | } |
| 169 | |
| 170 | add_filter( 'ctf_admin_show_hide_list', 'ctf_show_hide_list', 10, 1 ); |
| 171 | function ctf_show_hide_list( $show_hide_list ) { |
| 172 | $show_hide_list[] = array( 'include_replied_to', 'In reply to text' ); |
| 173 | $show_hide_list[] = array( 'include_media', 'Media (images, videos, gifs)' ); |
| 174 | $show_hide_list[] = array( 'include_twittercards', 'Twitter Cards' ); |
| 175 | return $show_hide_list; |
| 176 | } |
| 177 | |
| 178 | function ctf_pro_autoscroll_section() { |
| 179 | ?> |
| 180 | <p class="ctf_pro_section_note"><a href="https://smashballoon.com/custom-twitter-feeds/?utm_campaign=twitter-free&utm_source=settings&utm_medium=autoscroll" target="_blank">Upgrade to Pro to enable Autoscroll loading</a></p> |
| 181 | <span><a href="javascript:void(0);" class="button button-secondary ctf-show-pro"><b>+</b> Show Pro Options</a></span> |
| 182 | |
| 183 | <div class="ctf-pro-options"> |
| 184 | <table class="form-table"><tbody><tr><th scope="row"><label for="ctf_autoscroll" title="Click for shortcode option">Set Load More on Scroll as Default</label><code class="ctf_shortcode">autoscroll |
| 185 | Eg: autoscroll=true</code></th><td> <input name="ctf_options[autoscroll]" id="ctf_autoscroll" type="checkbox" disabled> |
| 186 | <a class="ctf-tooltip-link" href="JavaScript:void(0);" role="button" aria-label="More information"><i class="fa fa-question-circle" aria-hidden="true"></i></a> |
| 187 | <p class="ctf-tooltip ctf-more-info">This will make every Twitter feed load more Tweets as the user gets to the bottom of the feed.</p> |
| 188 | </td></tr><tr class="default-text"><th scope="row"><label for="ctf_autoscrolldistance">Auto Scroll Trigger Distance</label><code class="ctf_shortcode">autoscrolldistance |
| 189 | Eg: autoscrolldistance=2</code></th><td> <input name="ctf_options[autoscrolldistance]" id="ctf_autoscrolldistance" class="default-text" type="text" value="200" disabled> |
| 190 | <a class="ctf-tooltip-link" href="JavaScript:void(0);" role="button" aria-label="More information"><i class="fa fa-question-circle" aria-hidden="true"></i></a> |
| 191 | <p class="ctf-tooltip ctf-more-info">This is the distance in pixels from the bottom of the page the user must scroll to to trigger the loading of more tweets.</p> |
| 192 | </td></tr></tbody></table> |
| 193 | </div> |
| 194 | <div style="height: 18px;"></div> |
| 195 | <?php |
| 196 | } |
| 197 | |
| 198 | function ctf_pro_moderation_section() { |
| 199 | ?> |
| 200 | <p class="ctf_pro_section_note"><a href="https://smashballoon.com/custom-twitter-feeds/?utm_campaign=twitter-free&utm_source=settings&utm_medium=moderation" target="_blank">Upgrade to Pro to enable Tweet moderation</a></p> |
| 201 | <span><a href="javascript:void(0);" class="button button-secondary ctf-show-pro"><b>+</b> Show Pro Options</a></span> |
| 202 | |
| 203 | <div class="ctf-pro-options"> |
| 204 | <table class="form-table"><tbody><tr class="large-text"><th scope="row"><label for="ctf_includewords" title="Click for shortcode option">Show Tweets containing these words or hashtags</label><code class="ctf_shortcode">includewords |
| 205 | Eg: includewords="#puppy,#cute"</code></th><td> <input name="ctf_options[includewords]" id="ctf_includewords" class="large-text" type="text" value="" disabled> |
| 206 | <span>"includewords" separate words by comma</span> |
| 207 | </td></tr><tr class="large-text"><th scope="row"><label for="ctf_excludewords">Remove Tweets containing these words or hashtags</label><code class="ctf_shortcode">excludewords |
| 208 | Eg: excludewords="#ugly,#bad"</code></th><td> <input name="ctf_options[excludewords]" id="ctf_excludewords" class="large-text" type="text" value="" disabled> |
| 209 | <span>"excludewords" separate words by comma</span> |
| 210 | </td></tr><tr><th scope="row"></th><td> <p>Show Tweets that contain |
| 211 | <select name="ctf_options[includeanyall]" id="ctf_includeanyall" disabled> |
| 212 | <option value="any" selected="selected">any</option> |
| 213 | <option value="all">all</option> |
| 214 | </select> |
| 215 | of the "includewords" |
| 216 | <select name="ctf_options[filterandor]" id="ctf_filterandor" disabled> |
| 217 | <option value="and" selected="selected">and</option> |
| 218 | <option value="or">or</option> |
| 219 | </select> |
| 220 | do not contain |
| 221 | <select name="ctf_options[excludeanyall]" id="ctf_excludeanyall" disabled> |
| 222 | <option value="any" selected="selected">any</option> |
| 223 | <option value="all">all</option> |
| 224 | </select> |
| 225 | of the "excludewords" |
| 226 | </p> |
| 227 | </td></tr><tr><th scope="row"><label for="ctf_remove_by_id">Hide Specific Tweets</label></th><td> <textarea name="ctf_options[remove_by_id]" id="ctf_remove_by_id" style="width: 70%;" rows="3" disabled></textarea> |
| 228 | <p>separate IDs by comma <a class="ctf-tooltip-link" href="JavaScript:void(0);" role="button" aria-label="More information"><i class="fa fa-question-circle" aria-hidden="true"></i></a> |
| 229 | <span class="ctf-tooltip ctf-more-info">These are the specific ID numbers associated with a tweet. You can find the ID of a Tweet by viewing the Tweet on Twitter and copy/pasting the ID number from the end of the URL.</span> |
| 230 | </p> </td></tr></tbody></table> |
| 231 | </div> |
| 232 | <div style="height: 18px;"></div> |
| 233 | <?php |
| 234 | } |
| 235 | |
| 236 | add_action( 'ctf_admin_style_option', 'ctf_add_masonry_autoscroll_options', 5, 1 ); |
| 237 | function ctf_add_masonry_autoscroll_options( $admin ) { |
| 238 | // custom in reply to text |
| 239 | $admin->create_settings_field( array( |
| 240 | 'name' => 'inreplytotext', |
| 241 | 'title' => '<label for="ctf_inreplytotext">Translation for "In reply to"</label><code class="ctf_shortcode">inreplytotext |
| 242 | Eg: inreplytotext="Als Antwort an"</code>', // label for the input field |
| 243 | 'callback' => 'default_text', // name of the function that outputs the html |
| 244 | 'page' => 'ctf_options_text', // matches the section name |
| 245 | 'section' => 'ctf_options_text', // matches the section name |
| 246 | 'option' => 'ctf_options', // matches the options name |
| 247 | 'class' => 'default-text ctf_pro', // class for the wrapper and input field |
| 248 | 'whatis' => 'This will replace the default text displayed for "In reply to"', |
| 249 | 'default' => 'In reply to'// "what is this?" text |
| 250 | ) ); |
| 251 | |
| 252 | add_settings_section( |
| 253 | 'ctf_options_autoscroll', // matches the section name |
| 254 | '<span class="ctf_pro_header">Autoscroll Loading</span>', |
| 255 | 'ctf_pro_autoscroll_section', // callback function to explain the section |
| 256 | 'ctf_options_autoscroll' // matches the section name |
| 257 | ); |
| 258 | |
| 259 | add_settings_section( |
| 260 | 'ctf_options_filter', // matches the section name |
| 261 | '<span class="ctf_pro_header">Moderation</span>', |
| 262 | 'ctf_pro_moderation_section', // callback function to explain the section |
| 263 | 'ctf_options_filter' // matches the section name |
| 264 | ); |
| 265 | } |
| 266 | |
| 267 | add_action( 'ctf_admin_customize_option', 'ctf_add_customize_general_options', 20, 1 ); |
| 268 | function ctf_add_customize_general_options( $admin ) { |
| 269 | |
| 270 | // Disable the lightbox |
| 271 | $admin->create_settings_field( array( |
| 272 | 'name' => 'disablelightbox', |
| 273 | 'title' => '<label for="ctf_disablelightbox">Disable the lightbox</label><code class="ctf_shortcode">disablelightbox |
| 274 | Eg: disablelightbox=true</code>', // label for the input field |
| 275 | 'callback' => 'default_checkbox', // name of the function that outputs the html |
| 276 | 'page' => 'ctf_options_general', // matches the section name |
| 277 | 'section' => 'ctf_options_general', // matches the section name |
| 278 | 'option' => 'ctf_options', // matches the options name |
| 279 | 'class' => 'default-text ctf_pro', // class for the wrapper and input field |
| 280 | 'whatis' => 'Disable the popup lightbox for media in the feed' |
| 281 | ) ); |
| 282 | } |
| 283 | |
| 284 | |
| 285 | add_action( 'ctf_admin_customize_option', 'ctf_add_filter_options', 10, 1 ); |
| 286 | function ctf_add_filter_options( $admin ) { |
| 287 | |
| 288 | add_settings_field( |
| 289 | 'clear_tc_cache_button', |
| 290 | '<label for="ctf_clear_tc_cache_button">Clear Twitter Card Cache</label>', |
| 291 | 'ctf_clear_tc_cache_button', |
| 292 | 'ctf_options_advanced', |
| 293 | 'ctf_options_advanced', |
| 294 | array( 'class' => 'ctf_pro') |
| 295 | ); |
| 296 | } |
| 297 | |
| 298 | function ctf_remove_by_id( $args ) { |
| 299 | $options = get_option( $args['option'] ); |
| 300 | $option_string = ( isset( $options[ $args['name'] ] ) ) ? esc_attr( $options[ $args['name'] ] ) : ''; |
| 301 | ?> |
| 302 | <textarea name="<?php echo $args['option'].'['.$args['name'].']'; ?>" id="ctf_<?php echo $args['name']; ?>" style="width: 70%;" rows="3"><?php esc_attr_e( stripslashes( $option_string ) ); ?></textarea> |
| 303 | <?php if ( isset( $args['extra'] ) ) : ?><p><?php _e( $args['extra'], 'custom-twitter-feeds' ); ?> |
| 304 | <a class="ctf-tooltip-link" href="JavaScript:void(0);" role="button" aria-label="More information"><span class="fa fa-question-circle" aria-hidden="true"></span></a> |
| 305 | <span class="ctf-tooltip ctf-more-info"><?php _e( $args['whatis'], 'custom-twitter-feeds' ); ?>.</span> |
| 306 | </p> <?php endif; ?> |
| 307 | <?php |
| 308 | } |
| 309 | |
| 310 | function ctf_clear_tc_cache_button() { |
| 311 | ?> |
| 312 | <input id="ctf-clear-tc-cache" class="button-secondary" style="margin-top: 1px;" type="submit" value="<?php esc_attr_e( 'Clear Twitter Cards' ); ?>" /> |
| 313 | <a class="ctf-tooltip-link" href="JavaScript:void(0);" role="button" aria-label="More information"><span class="fa fa-question-circle" aria-hidden="true"></span></a> |
| 314 | <p class="ctf-tooltip ctf-more-info"><?php _e( 'Clicking this button will clear all cached data for your links that have Twitter Cards', 'custom-twitter-feeds' ); ?>.</p> |
| 315 | <?php |
| 316 | } |
| 317 | |
| 318 | function ctf_filter_operator( $args ) { |
| 319 | $options = get_option( $args['option'] ); |
| 320 | $include_any_all = ( isset( $options['includeanyall'] ) ) ? esc_attr( $options['includeanyall'] ) : 'any'; |
| 321 | $filter_and_or = ( isset( $options['filterandor'] ) ) ? esc_attr( $options['filterandor'] ) : 'and'; |
| 322 | $exclude_any_all = ( isset( $options['excludeanyall'] ) ) ? esc_attr( $options['excludeanyall'] ) : 'any'; |
| 323 | |
| 324 | ?> |
| 325 | <p>Show Tweets that contain |
| 326 | <select name="<?php echo $args['option'].'[includeanyall]'; ?>" id="ctf_includeanyall"> |
| 327 | <option value="any" <?php if ( $include_any_all == "any" ) echo 'selected="selected"'; ?> ><?php _e('any'); ?></option> |
| 328 | <option value="all" <?php if ( $include_any_all == "all" ) echo 'selected="selected"'; ?> ><?php _e('all'); ?></option> |
| 329 | </select> |
| 330 | of the "includewords" |
| 331 | <select name="<?php echo $args['option'].'[filterandor]'; ?>" id="ctf_filterandor"> |
| 332 | <option value="and" <?php if ( $filter_and_or == "and" ) echo 'selected="selected"'; ?> ><?php _e('and'); ?></option> |
| 333 | <option value="or" <?php if ( $filter_and_or == "or" ) echo 'selected="selected"'; ?> ><?php _e('or'); ?></option> |
| 334 | </select> |
| 335 | do not contain |
| 336 | <select name="<?php echo $args['option'].'[excludeanyall]'; ?>" id="ctf_excludeanyall"> |
| 337 | <option value="any" <?php if ( $exclude_any_all == "any" ) echo 'selected="selected"'; ?> ><?php _e('any'); ?></option> |
| 338 | <option value="all" <?php if ( $exclude_any_all == "all" ) echo 'selected="selected"'; ?> ><?php _e('all'); ?></option> |
| 339 | </select> |
| 340 | of the "excludewords" |
| 341 | </p> |
| 342 | <?php if ( isset( $args['whatis'] ) ) : ?> |
| 343 | <a class="ctf-tooltip-link" href="JavaScript:void(0);" role="button" aria-label="More information"><span class="fa fa-question-circle" aria-hidden="true"></span></a> |
| 344 | <p class="ctf-tooltip ctf-more-info"><?php _e( $args['whatis'], 'custom-twitter-feeds' ); ?>.</p> |
| 345 | <?php endif; ?> |
| 346 | <?php |
| 347 | } |
| 348 | |
| 349 | add_action( 'ctf_admin_add_settings_sections_to_customize', 'ctf_add_masonry_autoload_section_to_customize' ); |
| 350 | function ctf_add_masonry_autoload_section_to_customize() { |
| 351 | ?> |
| 352 | <a id="autoscroll"></a> |
| 353 | <?php do_settings_sections( 'ctf_options_autoscroll' ); ?> |
| 354 | <!-- <p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p> --> |
| 355 | <hr> |
| 356 | <?php |
| 357 | } |
| 358 | |
| 359 | add_action( 'ctf_admin_add_settings_sections_to_customize', 'ctf_add_filter_section_to_customize' ); |
| 360 | function ctf_add_filter_section_to_customize() { |
| 361 | echo '<a id="moderation"></a>'; |
| 362 | do_settings_sections( 'ctf_options_filter' ); // matches the section name |
| 363 | echo '<hr>'; |
| 364 | } |
| 365 | |
| 366 | function ctf_lite_dismiss() { |
| 367 | $cap = ctf_get_manage_options_cap(); |
| 368 | |
| 369 | if ( ! current_user_can( $cap ) ) { |
| 370 | wp_send_json_error(); // This auto-dies. |
| 371 | } |
| 372 | |
| 373 | $nonce = isset( $_POST['ctf_nonce'] ) ? sanitize_text_field( $_POST['ctf_nonce'] ) : ''; |
| 374 | |
| 375 | if ( ! wp_verify_nonce( $nonce, 'ctf-smash-balloon' ) ) { |
| 376 | die ( 'You did not do this the right way!' ); |
| 377 | } |
| 378 | |
| 379 | set_transient( 'twitter_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS ); |
| 380 | |
| 381 | die(); |
| 382 | } |
| 383 | add_action( 'wp_ajax_ctf_lite_dismiss', 'ctf_lite_dismiss' ); |
| 384 | |
| 385 | function ctf_admin_hide_unrelated_notices() { |
| 386 | |
| 387 | // Bail if we're not on a ctf screen or page. |
| 388 | if ( ! isset( $_GET['page'] ) |
| 389 | || ($_GET['page'] !== 'custom-twitter-feeds' && $_GET['page'] !== 'ctf-sw') ) { |
| 390 | return; |
| 391 | } |
| 392 | |
| 393 | // Extra banned classes and callbacks from third-party plugins. |
| 394 | $blacklist = array( |
| 395 | 'classes' => array(), |
| 396 | 'callbacks' => array( |
| 397 | 'ctfdb_admin_notice', // 'Database for ctf' plugin. |
| 398 | ), |
| 399 | ); |
| 400 | |
| 401 | global $wp_filter; |
| 402 | |
| 403 | foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) { |
| 404 | if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) { |
| 405 | continue; |
| 406 | } |
| 407 | foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) { |
| 408 | foreach ( $hooks as $name => $arr ) { |
| 409 | if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) { |
| 410 | unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] ); |
| 411 | continue; |
| 412 | } |
| 413 | $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : ''; |
| 414 | if ( |
| 415 | ! empty( $class ) && |
| 416 | strpos( $class, 'ctf' ) !== false && |
| 417 | ! in_array( $class, $blacklist['classes'], true ) |
| 418 | ) { |
| 419 | continue; |
| 420 | } |
| 421 | if ( |
| 422 | ! empty( $name ) && ( |
| 423 | strpos( $name, 'ctf' ) === false || |
| 424 | in_array( $class, $blacklist['classes'], true ) || |
| 425 | in_array( $name, $blacklist['callbacks'], true ) |
| 426 | ) |
| 427 | ) { |
| 428 | unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] ); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | add_action( 'admin_print_scripts', 'ctf_admin_hide_unrelated_notices' ); |
| 435 |