Ejemplo n.º 1
0
/**
 * Add Like Button(s) to post content.
 *
 * Adds a like button above the post, below the post, or both above and below the post depending on stored preferences.
 *
 * @since 1.1
 *
 * @global stdClass|WP_Post $post WordPress post. Used to request a post permalink.
 * @param string $content existing content
 * @return string passed content with Like Button markup prepended, appended, or both.
 */
function facebook_the_content_like_button($content)
{
    global $post;
    // Like Buttons should not be the only content in the post
    if (!$content) {
        return $content;
    }
    $options = get_option('facebook_like_button');
    if (!is_array($options)) {
        $options = array();
    }
    if (!isset($options['position'])) {
        return $content;
    }
    // duplicate_hook
    $options['href'] = apply_filters('facebook_rel_canonical', get_permalink($post->ID));
    if ($options['position'] === 'top') {
        $options['ref'] = 'above-post';
        return facebook_get_like_button($options) . $content;
    } else {
        if ($options['position'] === 'bottom') {
            $options['ref'] = 'below-post';
            return $content . facebook_get_like_button($options);
        } else {
            if ($options['position'] === 'both') {
                $options['ref'] = 'above-post';
                $above = facebook_get_like_button($options);
                $options['ref'] = 'below-post';
                return $above . $content . facebook_get_like_button($options);
            }
        }
    }
    // don't break the filter
    return $content;
}
Ejemplo n.º 2
0
 /**
  * Generate a HTML div element with data-* attributes to be converted into a Like Button by the Facebook JavaScript SDK
  *
  * @since 1.1.6
  * @param array $attributes shortcode attributes. overrides site options for specific button attributes
  * @param string $content shortcode content. no effect
  */
 public static function like_button($attributes, $content = null)
 {
     global $post;
     $site_options = get_option('facebook_like_button');
     if (!is_array($site_options)) {
         $site_options = array();
     }
     $options = shortcode_atts(array('href' => '', 'send' => isset($site_options['send']) && $site_options['send'], 'layout' => isset($site_options['layout']) ? $site_options['layout'] : '', 'show_faces' => isset($site_options['show_faces']) && $site_options['show_faces'], 'width' => isset($site_options['width']) ? $site_options['width'] : 0, 'action' => isset($site_options['action']) ? $site_options['action'] : '', 'font' => isset($site_options['font']) ? $site_options['font'] : '', 'colorscheme' => isset($site_options['colorscheme']) ? $site_options['colorscheme'] : '', 'ref' => 'shortcode'), $attributes, 'facebook_like_button');
     // check for valid href value. unset if not valid, allowing for a possible permalink replacement
     if (is_string($options['href']) && $options['href']) {
         $options['href'] = esc_url_raw($options['href'], array('http', 'https'));
     }
     if (!(is_string($options['href']) && $options['href'])) {
         unset($options['href']);
         if (isset($post)) {
             $options['href'] = apply_filters('facebook_rel_canonical', get_permalink($post->ID));
         }
     }
     foreach (array('send', 'show_faces') as $bool_key) {
         $options[$bool_key] = (bool) $options[$bool_key];
     }
     $options['width'] = absint($options['width']);
     if ($options['width'] < 1) {
         unset($options['width']);
     }
     foreach (array('layout', 'action', 'font', 'colorscheme', 'ref') as $key) {
         $options[$key] = trim($options[$key]);
         if (!$options[$key]) {
             unset($options[$key]);
         }
     }
     if (!function_exists('facebook_get_like_button')) {
         require_once dirname(__FILE__) . '/social-plugins.php';
     }
     return facebook_get_like_button($options);
 }
Ejemplo n.º 3
0
	<?php 
if (is_search()) {
    ?>
	<div class="entry-summary">
		<?php 
    the_excerpt();
    ?>
	</div><!-- .entry-summary -->
	<?php 
} else {
    ?>
	<div class="entry-content">
		  <?php 
    if (function_exists(facebook_get_like_button)) {
        $options = get_option('facebook_like_button');
        echo facebook_get_like_button($options);
    }
    ?>
		<form id="quiz-form" method="post">
		<?php 
    $questions = get_field('questions');
    if ($questions) {
        $questions = rand_array_value($questions);
        echo '<h1 id="result">Total: <span id="total_count">' . count($questions) . '</span> questions</h1>';
        echo '<ul>';
        foreach ($questions as $key => $question) {
            echo '<li class="answer">';
            echo '<h6><img src="/images/wrong.png" width="20px" class="correct_icon">' . ($key + 1) . '. ' . htmlspecialchars_decode($question['question']) . '</h6>';
            $ans = $question['answer'];
            if ($ans) {
                $htmtrue = '';