コード例 #1
0
 /**
  * Renders view.
  *
  * @param WP_Post $post The current post / page.
  */
 public function __render($post)
 {
     wp_nonce_field($this->slug, $this->slug . '-nonce');
     $pinterest_meta = WP_Pinterest::get_instance()->get_post_pinterest_meta($post);
     echo '<fieldset>';
     echo '<ul>';
     echo '<li>';
     echo '<label for="pinterest-url">URL</label>';
     echo '<input id="pinterest-url" name="pinterest-url" type="text" value="' . $pinterest_meta['url'] . '" />';
     echo '</li>';
     echo '<li>';
     echo '<label for="pinterest-description">Description</label>';
     echo '<input id="pinterest-description" name="pinterest-description" type="text" value="' . $pinterest_meta['description'] . '" />';
     echo '</li>';
     echo '<li>';
     echo '<label for="pinterest-image">Image</label>';
     echo '<input id="pinterest-image" name="pinterest-image" type="text" value="' . $pinterest_meta['image'] . '" />';
     echo '</li>';
     echo '<li>';
     echo '<label for="pinterest-hover">Hover</label>';
     echo '<select id="pinterest-hover" name="pinterest-hover">';
     echo '<option value="true" ' . selected($pinterest_meta['hover'], 'true', false) . '>';
     echo 'Enable';
     echo '</option>';
     echo '<option value="false" ' . selected($pinterest_meta['hover'], 'false', false) . '>';
     echo 'Disable';
     echo '</option>';
     echo '</select>';
     echo '</li>';
     echo '</ul>';
     echo '</fieldset>';
 }
コード例 #2
0
 /**
  * Gets instance of class.
  *
  * @return WP_Pinterest Instance of the class.
  */
 public static function get_instance()
 {
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #3
0
 /**
  * Initializes view.
  */
 public function __initialize()
 {
     global $post;
     $pinterest_meta = WP_Pinterest::get_instance()->get_post_pinterest_meta($post);
     // Add Pinterest meta.
     echo '<meta name="pinterest" content="nohover" />';
     echo '<meta property="pinterest:description" content="' . $pinterest_meta['description'] . '" />' . PHP_EOL;
     echo '<meta property="pinterest:hover" content="' . $pinterest_meta['hover'] . '" />' . PHP_EOL;
     echo '<meta property="pinterest:image" content="' . $pinterest_meta['image'] . '" />' . PHP_EOL;
     echo '<meta property="pinterest:url" content="' . $pinterest_meta['url'] . '" />' . PHP_EOL;
 }
コード例 #4
0
 /**
  * Renders view.
  *
  * @param array $attributes Shortcode attributes.
  * @return string Rendered shortcode.
  */
 public function __render($attributes)
 {
     global $post;
     $sharer_url = WP_Pinterest::get_instance()->get_sharer_url($post);
     $button_path = realpath(__DIR__ . '/../images/pin-it-button.png');
     $button_url = WP_Url_Util::get_instance()->convert_absolute_path_to_url($button_path);
     $html = '';
     $html .= '<span class="pin-it-button">';
     $html .= '<a class="pin-it" href="' . $sharer_url . '">';
     $html .= '<img src="' . $button_url . '" data-pin-no-hover="true" />';
     $html .= '</a>';
     $html .= '</span>';
     return $html;
 }
コード例 #5
0
 /**
  * Enqueues styles.
  */
 public function __enqueue_styles()
 {
     if (!apply_filters('wp_pinterest_load_default_styles', true)) {
         return;
     }
     $wp_pinterest = WP_Pinterest::get_instance();
     $wp_enqueue_util = WP_Enqueue_Util::get_instance();
     $handle = $wp_pinterest->get_slug() . '-styles';
     $relative_path = __DIR__ . '/../site/css/';
     $filename = 'wp-pinterest.min.css';
     $filename_debug = 'wp-pinterest.css';
     $dependencies = array();
     $options = new WP_Enqueue_Options($handle, $relative_path, $filename, $filename_debug, $dependencies, $wp_pinterest->get_version());
     $wp_enqueue_util->enqueue_style($options);
 }
 /**
  * Enqueues styles.
  */
 public function __enqueue_styles()
 {
     $wp_pinterest = WP_Pinterest::get_instance();
     $wp_post_type_util = WP_Post_Type_Util::get_instance();
     if ($wp_post_type_util->is_post_type_add_or_edit_screen('post') || $wp_post_type_util->is_post_type_add_or_edit_screen('page')) {
         $wp_enqueue_util = WP_Enqueue_Util::get_instance();
         $handle = $wp_pinterest->get_slug() . '-admin-styles';
         $relative_path = __DIR__ . '/../admin/css/';
         $filename = 'wp-pinterest-admin.min.css';
         $filename_debug = 'wp-pinterest-admin.css';
         $dependencies = array();
         $options = new WP_Enqueue_Options($handle, $relative_path, $filename, $filename_debug, $dependencies, $wp_pinterest->get_version());
         $wp_enqueue_util->enqueue_style($options);
     }
 }
コード例 #7
0
 /**
  * Enqueues scripts.
  */
 public function __enqueue_scripts()
 {
     $wp_enqueue_util = WP_Enqueue_Util::get_instance();
     $wp_pinterest = WP_Pinterest::get_instance();
     $handle = $wp_pinterest->get_slug() . '-scripts';
     $relative_path = __DIR__ . '/../site/js/';
     $filename = 'bundle.min.js';
     $filename_debug = 'bundle.concat.js';
     $dependencies = array();
     $version = $wp_pinterest->get_version();
     $options = new WP_Enqueue_Options($handle, $relative_path, $filename, $filename_debug, $dependencies, $version, true);
     $localization_name = 'wp_pinterest';
     $options->set_localization($localization_name, $this->get_data());
     $wp_enqueue_util->enqueue_script($options);
 }