Usage
nebula()->twitter_follow($counts, $username)
Parameters
$counts
(Optional) (Boolean) Whether to show count bubble
Default: false
$username
(Optional) (String) The username to follow
Default: Twitter Username (Nebula Option)
Parameter Notes
If a username is not passed and the Twitter Username Nebula option is empty, this function will return false.
Examples
Only show count bubbles to staff.
<?php nebula()->twitter_follow(nebula()->is_staff()); ?>
Source File
Located in /libs/Functions.php on line 1190.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"pre_nebula_twitter_follow"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?Note: This function contains 1 to-do comment.
public function twitter_follow($counts=0, $username=false){ $override = apply_filters('pre_nebula_twitter_follow', null, $counts, $username); if ( isset($override) ){return;} if ( empty($username) && !$this->get_option('twitter_username') ){ return false; } elseif ( empty($username) && $this->get_option('twitter_username') ){ $username = $this->get_option('twitter_username'); } elseif ( strpos($username, '@') === false ){ //@todo "Nebula" 0: Update strpos() to str_contains() in PHP8 $username = '@' . $username; } ?> <div class="nebula-social-button twitter-follow"> <a href="https://twitter.com/<?php echo str_replace('@', '', $username); ?>" class="twitter-follow-button" <?php echo ( $counts !== 0 )? '': 'data-show-count="false"'; ?> <?php echo ( !empty($username) )? '': 'data-show-screen-name="false"'; ?>><?php echo __('Follow', 'nebula') . ' ' . $username; ?></a> <?php $this->twitter_widget_script(); ?> </div> <?php }
Override
To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):
add_filter('pre_nebula_twitter_follow', 'my_custom_twitter_follow', 10, 3); //The last integer must be 1 more than the actual parameters function my_custom_twitter_follow($null, $counts, $username){ //$null is required, but can be ignored //Write your own code here return true; //Return true to prevent the original function from running afterwords }
You can completely disable this PHP function with a single line actions:
add_filter('pre_nebula_twitter_follow', '__return_false');