/**
  * Get accessor method for instance property.
  *
  * @return WP_Url_Util Instance of the class.
  */
 public static function get_instance()
 {
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Enqueues scripts.
  *
  * @param $queue array List of enqueued Grunticon assets.
  * @return array Filtered list of enqueued Grunticon assets.
  */
 function __enqueue_scripts($queue)
 {
     $wp_recipe = WP_Recipe::get_instance();
     $wp_url_util = WP_Url_Util::get_instance();
     $wp_grunticon_options = new WP_Grunticon_Options($wp_url_util->convert_absolute_path_to_root_path(realpath(__DIR__ . '/../admin/css/images')), 'svg.css', 'png.css', 'fallback.css', $wp_recipe->get_version());
     array_push($queue, $wp_grunticon_options);
     return $queue;
 }
 /**
  * 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;
 }
 /**
  * Gets the source to enqueue based upon whether or not debugging is enabled.
  *
  * @param $relative_path string Relative path to the potential files to enqueue.
  * @param $filename string Filename of the production file to enqueue.
  * @param $filename_debug string Filename of the file to enqueue when debugging.
  * @return string A url to the source to enqueue.
  */
 public function get_source_to_enqueue($relative_path, $filename, $filename_debug = null)
 {
     $source_file = $filename;
     if (defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG && !empty($filename_debug)) {
         $source_file = $filename_debug;
     }
     $path = realpath(trailingslashit($relative_path) . $source_file);
     return WP_Url_Util::get_instance()->convert_absolute_path_to_url($path);
 }
 /**
  * Gets the first image inside of HTML.
  *
  * @param string $content Content with some markup, usually post content.
  * @param string $fallback Optional. URL of fallback image to use, if none are found in HTML.
  * @return string URL of first image.
  */
 public function get_first_image($content, $fallback = '')
 {
     $wp_url_util = WP_Url_Util::get_instance();
     $images = $this->get_image_elements($content);
     if ($images->length) {
         foreach ($images as $image) {
             $image_source = $image->getAttribute('src');
             $image_source = $wp_url_util->remove_query_string($image_source);
             if (!empty($image_source)) {
                 return $image_source;
             }
         }
     }
     return $fallback;
 }
 protected function setUp()
 {
     $this->wp_url_util = WP_Url_Util::get_instance();
 }