/** * Gets info about the current site. * * @since 1.0.0 * @access private * * @param array $atts The attributes sent to the shortcode. * * @return string The desired blog info. */ function _render_sc_site_info($atts = array()) { $atts = shortcode_atts(array('info' => 'name'), $atts); // Escape atts render_esc_atts($atts); $output = get_bloginfo($atts['info']); // Default bloginfo is the name, so if it returns name, but we didn't ask for name, it was an invalid option if ($output == get_bloginfo('name') && $atts['info'] !== 'name') { $output = render_sc_error('Not a valid option.'); } return $output; }
/** * Gets the post word count. * * @since 0.3.0 * @access private * * @param array $atts The attributes sent to the shortcode. * * @return string The post word count. */ function _render_sc_post_word_count($atts = array()) { $atts = shortcode_atts(array('post' => get_the_ID()), $atts); // Escape atts render_esc_atts($atts); // Get the post object if (($post = get_post($atts['post'])) === null) { return render_sc_error('Cannot get post object.'); } // Get the filtered content $content = $post->post_content; // Strip this shortcode out to count the rest $content = preg_replace("/\\[render_post_word_count]/s", '', $content); $content = do_shortcode($content); // Strip tags $content = strip_tags($content); // Convert nbsp to real space $content = preg_replace('/ /', ' ', $content); // And then count it! return str_word_count($content); }
/** * Gets the date the current user registered. * * @since 1.0.0 * @access private * * @param object $user The user object. * @param array $atts The attributes sent to the shortcode. * * @return string The the date the current user registered. */ function _render_sc_user_user_registered($user, $atts = array()) { if ($atts['date_format'] == 'default_date') { $atts['date_format'] = get_option('date_format', 'F jS, Y'); } if (isset($user['user_registered'])) { return date($atts['date_format'], strtotime($user['user_registered'])); } else { return render_sc_error('Cannot get user email address.'); } }