/**
  * Fix the Facebook embed handling
  *
  */
 private function _fix_facebook_embed()
 {
     // All of these are registered in jetpack/modules/shortcodes/facebook.php
     if (defined('JETPACK_FACEBOOK_EMBED_REGEX')) {
         wp_embed_unregister_handler('facebook');
         wp_embed_register_handler('facebook', JETPACK_FACEBOOK_EMBED_REGEX, array(__CLASS__, 'facebook_embed_handler'));
     }
     if (defined('JETPACK_FACEBOOK_ALTERNATE_EMBED_REGEX')) {
         wp_embed_unregister_handler('facebook-alternate');
         wp_embed_register_handler('facebook-alternate', JETPACK_FACEBOOK_ALTERNATE_EMBED_REGEX, array(__CLASS__, 'facebook_embed_handler'));
     }
     if (defined('JETPACK_FACEBOOK_PHOTO_EMBED_REGEX')) {
         wp_embed_unregister_handler('facebook-photo');
         wp_embed_register_handler('facebook-photo', JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, array(__CLASS__, 'facebook_embed_handler'));
     }
     if (defined('JETPACK_FACEBOOK_PHOTO_ALTERNATE_EMBED_REGEX')) {
         wp_embed_unregister_handler('facebook-alternate-photo');
         wp_embed_register_handler('facebook-alternate-photo', JETPACK_FACEBOOK_PHOTO_ALTERNATE_EMBED_REGEX, array(__CLASS__, 'facebook_embed_handler'));
     }
     if (defined('JETPACK_FACEBOOK_VIDEO_EMBED_REGEX')) {
         wp_embed_unregister_handler('facebook-video');
         wp_embed_register_handler('facebook-video', JETPACK_FACEBOOK_VIDEO_EMBED_REGEX, array(__CLASS__, 'facebook_embed_handler'));
     }
     if (defined('JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX')) {
         wp_embed_unregister_handler('facebook-alternate-video');
         wp_embed_register_handler('facebook-alternate-video', JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, array(__CLASS__, 'facebook_embed_handler'));
     }
 }
Пример #2
0
 public function plugins_loaded()
 {
     add_action('wp_head', array($this, 'wp_head'));
     load_plugin_textdomain('oembed-gist', false, dirname(plugin_basename(__FILE__)) . '/languages');
     wp_embed_register_handler('oe-gist', $this->get_gist_regex(), array($this, 'handler'));
     add_shortcode($this->get_shortcode_tag(), array($this, 'shortcode'));
     add_filter('jetpack_shortcodes_to_include', array($this, 'jetpack_shortcodes_to_include'));
 }
Пример #3
0
 /**
  * Register shortcode macro and handler
  *
  * @since 1.3.0
  *
  * @return void
  */
 public static function init()
 {
     add_shortcode(static::SHORTCODE_TAG, array(__CLASS__, 'shortcodeHandler'));
     // pass a Periscope profile URL through the Periscope On Air shortcode handler
     wp_embed_register_handler(self::SHORTCODE_TAG, static::PERISCOPE_PROFILE_URL_REGEX, array(__CLASS__, 'linkHandler'), 1);
     // Shortcode UI, if supported
     add_action('register_shortcode_ui', array(__CLASS__, 'shortcodeUI'), 5, 0);
 }
Пример #4
0
 public function plugins_loaded()
 {
     add_action('wp_enqueue_scripts', array($this, 'enquene_script'));
     add_action('wp_head', array($this, 'wp_head'));
     load_plugin_textdomain('oembed-travis', false, plugins_url(implode(array('languages'), DIRECTORY_SEPARATOR), __FILE__));
     wp_embed_register_handler('oembed-travis', $this->get_travis_url_regex(), array($this, 'handler'));
     add_shortcode($this->get_shortcode_tag(), array($this, 'shortcode'));
 }
Пример #5
0
 /**
  * Set up the plugin.
  *
  * Adds a [gist] shortcode to do the bulk of the heavy lifting. An embed
  * handler is registered to mimic oEmbed functionality, but it relies on
  * the shortcode for processing.
  *
  * Supported formats:
  *
  * * Old link: https://gist.github.com/{{id}}#file_{{filename}}
  * * Old link with username: https://gist.github.com/{{user}}/{{id}}#file_{{filename}}
  * * New bookmark: https://gist.github.com/{{id}}#file-{{file_slug}}
  * * New bookmark with username: https://gist.github.com/{{user}}/{{id}}#file-{{sanitized-filename}}
  *
  * @since 1.1.0
  */
 public function run()
 {
     $oembed_pattern = '#https://gist\\.github\\.com/(?:.*/)?([a-z0-9]+)(?:\\#file([_-])(.*))?#i';
     wp_embed_register_handler('gist', $oembed_pattern, array($this, 'wp_embed_handler'));
     add_shortcode('gist', array($this, 'shortcode'));
     add_action('init', array($this, 'style'), 15);
     add_action('post_updated', array($this, 'delete_gist_transients'), 10, 3);
 }
 public static function init()
 {
     /**
      * Add new handler
      * provider
      * e.g. <iframe src='https://fr.tuto.com/embed/preview/53781/' width='560' height='356' frameborder='0' scrolling='auto' allowfullscreen></iframe>
      */
     wp_embed_register_handler('embed-tuto', apply_filters('tuto_oembed/regex', '#https?:\\/\\/fr\\.tuto\\.com\\/embed\\/preview\\/([\\d]+)\\/?#i'), array(__CLASS__, 'register_handler'));
 }
Пример #7
0
 function plugins_loaded()
 {
     if (!defined('NPR_API_KEY_OPTION')) {
         return;
     }
     // http://www.npr.org/2010/11/20/131472499/hours-so-early-holiday-shoppers-stay-up-late
     wp_embed_register_handler('npr_api', '#http://www.npr.org/\\d{4}/\\d{1,2}/\\d{1,2}/(\\d{7,})/#i', array(&$this, 'embed_callback'));
     add_action('save_post', array(&$this, 'save_post'), 10, 2);
 }
Пример #8
0
 /**
  * Register shortcode macro and handler
  *
  * @since 1.0.0
  *
  * @return void
  */
 public static function init()
 {
     $classname = get_called_class();
     add_shortcode(static::SHORTCODE_TAG, array($classname, 'shortcodeHandler'));
     // convert a URL into the shortcode equivalent
     wp_embed_register_handler(static::SHORTCODE_TAG, static::URL_REGEX, array($classname, 'linkHandler'), 1);
     // Shortcode UI, if supported
     add_action('register_shortcode_ui', array($classname, 'shortcodeUI'), 5, 0);
 }
Пример #9
0
 public function test_autoembed_should_return_modified_content()
 {
     $handle = rand_str();
     $regex = '#https?://example\\.com/embed/([^/]+)#i';
     $callback = array($this, '_embed_handler_callback');
     wp_embed_register_handler($handle, $regex, $callback);
     $content = "\nhttp://example.com/embed/foo\n";
     $actual = $GLOBALS['wp_embed']->autoembed($content);
     wp_embed_unregister_handler($handle);
     $this->assertEquals("\nEmbedded http://example.com/embed/foo\n", $actual);
 }
Пример #10
0
 /**
  * Attach handlers for Vine embeds
  *
  * @since 1.0.0
  *
  * @return void
  */
 public static function init()
 {
     // register our shortcode and its handler
     add_shortcode(self::SHORTCODE_TAG, array(__CLASS__, 'shortcodeHandler'));
     // register a preferred handler for the Vine URL pattern
     // matched URLs execute before the oEmbed handlers
     wp_embed_register_handler(self::SHORTCODE_TAG, self::URL_PATTERN, array(__CLASS__, 'linkHandler'), 1);
     // add Vine to the list of allowed oEmbed providers
     // fallback for functions that go straight to oEmbed
     wp_oembed_add_provider(self::URL_PATTERN, 'https://vine.co/oembed.{format}', true);
 }
Пример #11
0
 public function addPlugin($plugin)
 {
     $reflClass = new \ReflectionClass($plugin);
     if (!$this->getAnnotationReader()->getClassAnnotation($reflClass, 'Oow\\Plugin\\Annotations\\Plugin')) {
         throw new \InvalidArgumentException("{$reflClass->getName()} does not have any Oow\\Plugin\\Annotations\\Plugin annotation instance");
     }
     foreach ($reflClass->getMethods() as $method) {
         if ($method->isPublic()) {
             foreach ($this->getAnnotationReader()->getMethodAnnotations($method) as $annot) {
                 if ($annot instanceof Annotations\Hook) {
                     $tag = $annot->tag;
                     $function_to_add = array($plugin, $method->getName());
                     $priority = $annot->priority;
                     $accepted_args = $method->getNumberOfParameters();
                     add_filter($tag, $function_to_add, $priority, $accepted_args);
                 } elseif ($annot instanceof Annotations\Settings) {
                     $this->addPlugin($plugin->{$method->getName()}());
                 } elseif ($annot instanceof Annotations\Shortcode) {
                     $tag = $annot->tag;
                     $func = array($plugin, $method->getName());
                     add_shortcode($tag, $func);
                 } elseif ($annot instanceof Annotations\AjaxResponse) {
                     $closure = function () use($plugin, $method, $annot) {
                         if (isset($_REQUEST['_wpnonce']) && !wp_verify_nonce($_REQUEST['_wpnonce'], $annot->action)) {
                             $response = false;
                         } else {
                             $response = $plugin->{$method->getName()}();
                         }
                         if ($annot->json) {
                             wp_send_json($response);
                         } else {
                             echo $response;
                             wp_die();
                         }
                     };
                     add_action('wp_ajax_' . $annot->action, $closure);
                     if ($annot->nopriv) {
                         add_action('wp_ajax_nopriv_' . $annot->action, $closure);
                     }
                 } elseif ($annot instanceof Annotations\Embed) {
                     $id = $annot->id;
                     $regex = $annot->regex;
                     $func = array($plugin, $method->getName());
                     $priority = $annot->priority;
                     wp_embed_register_handler($id, $regex, $func, $priority);
                 }
             }
         }
     }
     return $this;
 }
Пример #12
0
 /**
  * Register shortcode handlers
  *
  * @since 1.1.6
  *
  * @uses add_shortcode()
  * @uses wp_embed_register_handler()
  * @return void
  */
 public static function init()
 {
     // expose social plugin markup using WordPress Shortcode API
     add_shortcode('facebook_like_button', array('Facebook_Shortcodes', 'like_button'));
     add_shortcode('facebook_send_button', array('Facebook_Shortcodes', 'send_button'));
     add_shortcode('facebook_follow_button', array('Facebook_Shortcodes', 'follow_button'));
     add_shortcode('facebook_embedded_post', array('Facebook_Shortcodes', 'embedded_post'));
     // Convert a Facebook URL possibly representing a public post into Facebook embedded post markup
     wp_embed_register_handler('facebook_embedded_post_vanity', '#^https?://www\\.facebook\\.com/([A-Za-z0-9\\.-]{2,50})/posts/([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
     wp_embed_register_handler('facebook_embedded_post_no_vanity', '#^https?://www\\.facebook\\.com/permalink\\.php\\?story_fbid=([\\d]+)&id=([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
     wp_embed_register_handler('facebook_embedded_post_activity', '#^https?://www\\.facebook\\.com/([A-Za-z0-9\\.-]{2,50})/activity/([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
     wp_embed_register_handler('facebook_embedded_post_question', '#^https?://www\\.facebook\\.com/questions/([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
     wp_embed_register_handler('facebook_embedded_post_photo', '#^https?://www\\.facebook\\.com/photo\\.php\\?fbid=([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
     wp_embed_register_handler('facebook_embedded_post_video', '#^https?://www\\.facebook\\.com/photo\\.php\\?v=([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
     wp_embed_register_handler('facebook_embedded_post_note', '#^https?://www\\.facebook\\.com/notes/([A-Za-z0-9\\.-]{2,50})/([^/]+)/([\\d]+)#i', array('Facebook_Shortcodes', 'wp_embed_handler_embedded_post'));
 }
Пример #13
0
function magyar_video_embed()
{
    wp_embed_unregister_handler('vivatvhu');
    wp_embed_unregister_handler('mtvcohu');
    wp_embed_unregister_handler('mnohu');
    wp_embed_unregister_handler('tv2hu');
    wp_embed_unregister_handler('rtlhu');
    wp_embed_register_handler('vivatvhu', '#http://(www\\.)?vivatv\\.hu/([0-9a-zA-Z\\-\\_\\/]+)/(?:videos)/([0-9a-zA-Z\\-\\_\\/]+)\\-([\\d]+)#i', 'wp_embed_handler_vivatvhu');
    wp_embed_register_handler('mtvcohu', '#http://(www\\.)?mtv\\.co\\.hu/([0-9a-zA-Z\\-\\_\\/]+)/(?:videos)/([0-9a-zA-Z\\-\\_\\/]+)\\-([\\d]+)#i', 'wp_embed_handler_mtvcohu');
    wp_embed_register_handler('mnohu', '#http://(www\\.)?mno\\.hu/(?:videok)/([\\d]+)#i', 'wp_embed_handler_mnohu');
    wp_embed_register_handler('tv2hu', '#http://(www\\.)?tv2\\.hu/(musoraink)/([0-9a-zA-Z\\.\\-\\_]+)/([\\d]+)_([0-9a-zA-Z\\.\\-\\_]+)#i', 'wp_embed_handler_tv2hu');
    wp_embed_register_handler('rtlhu', '#http://(www\\.)?rtl\\.hu/(rtlklub)/([0-9a-zA-Z\\-\\_\\/]+)#i', 'wp_embed_handler_rtlhu');
    wp_oembed_add_provider('#http://(www\\.)?noltv\\.hu/video/([\\d]+)\\.html#i', 'http://www.noltv.hu/services/oembed', true);
    wp_oembed_add_provider('#http://(www\\.)?indavideo\\.hu/video/(.*)#i', 'http://www.indavideo.hu/oembed', true);
    wp_oembed_add_provider('#http://(www\\.)?videa\\.hu/videok/(.*)#i', 'http://videa.hu/oembed', true);
    wp_oembed_add_provider('#http://(www\\.)?pixter\\.hu/video\\?id=(.*)#i', 'http://www.pixter.hu/oembed.{format}', true);
}
 public function __construct()
 {
     // Initialize private defaults.
     $this->prefix = $this->shortcode . '_';
     $this->dt_defaults = json_encode(array('dom' => "B<'clear'>lfrtip", 'buttons' => array('colvis', 'copy', 'csv', 'excel', 'pdf', 'print')));
     $this->capabilities = array($this->prefix . 'query_sql_databases');
     add_action('plugins_loaded', array($this, 'registerL10n'));
     add_action('init', array($this, 'maybeFetchGvizDataSource'));
     add_action('admin_init', array($this, 'registerSettings'));
     add_action('admin_menu', array($this, 'registerAdminMenu'));
     add_action('admin_head', array($this, 'doAdminHeadActions'));
     add_action('admin_enqueue_scripts', array($this, 'addAdminScripts'));
     add_action('admin_print_footer_scripts', array($this, 'addQuickTagButton'));
     add_action('wp_enqueue_scripts', array($this, 'addFrontEndScripts'));
     add_shortcode($this->shortcode, array($this, 'displayShortcode'));
     wp_embed_register_handler($this->shortcode . 'spreadsheet', $this->gdoc_url_regex, array($this, 'oEmbedHandler'));
     register_activation_hook(__FILE__, array($this, 'activate'));
 }
 /**
  * add filters
  */
 public function __construct()
 {
     add_filter('wpv_multiwidget_tab_title', array(&$this, 'multiwidget_tab_title'), 10, 3);
     add_action('wpv_multiwidget_single_title', array(&$this, 'multiwidget_single_title'), 10, 2);
     add_filter('wpv_posts_widget_thumbnail_name', array(&$this, 'posts_widget_thumbnail_name'), 10, 2);
     add_filter('wpv_posts_widget_img_size', array(&$this, 'posts_widget_img_size'), 10, 2);
     add_filter('wpv_column_title', array(&$this, 'column_title'), 10, 2);
     add_filter('excerpt_length', array(&$this, 'excerpt_length'));
     add_filter('excerpt_more', array(&$this, 'excerpt_more'));
     add_filter('wp_title', array(__CLASS__, 'wp_title'));
     remove_filter('the_content', 'li_display_love_link', 100);
     wp_embed_register_handler('wpv-swf', '#https?://[^\\s]+?.swf$#i', array(__CLASS__, 'embed_handler_swf'));
     add_filter('pre_option_page_for_posts', create_function('$value', 'return 0;'));
     add_filter('oembed_dataparse', array(&$this, 'oembed_dataparse'), 90, 3);
     add_action('layerslider_ready', array(&$this, 'layerslider_ready'));
     add_filter('nav_menu_css_class', array(__CLASS__, 'nav_menu_css_class'), 10, 3);
     add_action('wpv_before_post_content', array(__CLASS__, 'single_sermon_media'));
     add_action('wpv_body', array(__CLASS__, 'wpv_splash_screen'));
 }
Пример #16
0
 public function __construct()
 {
     if (is_admin()) {
         add_action('admin_menu', array($this, 'admin_menu'));
         $this->edit = true;
     }
     $option = get_option('smartideo_option');
     if (!empty($option)) {
         $option = json_decode($option, true);
     } else {
         $option = array();
     }
     $this->option = $option;
     extract($option);
     if (!empty($strategy)) {
         $this->strategy = $strategy;
     }
     if ($this->strategy != 1) {
         add_action('wp_enqueue_scripts', array($this, 'smartideo_scripts'));
     }
     wp_embed_unregister_handler('youku');
     wp_embed_unregister_handler('tudou');
     wp_embed_unregister_handler('56com');
     wp_embed_unregister_handler('youtube');
     // video
     wp_embed_register_handler('smartideo_tudou', '#https?://(?:www\\.)?tudou\\.com/(?:programs/view|listplay/(?<list_id>[a-z0-9_=\\-]+))/(?<video_id>[a-z0-9_=\\-]+)/#i', array($this, 'smartideo_embed_handler_tudou'));
     wp_embed_register_handler('smartideo_56', '#https?://(?:www\\.)?56\\.com/[a-z0-9]+/(?:play_album\\-aid\\-[0-9]+_vid\\-(?<video_id1>[a-z0-9_=\\-]+)|v_(?<video_id2>[a-z0-9_=\\-]+))#i', array($this, 'smartideo_embed_handler_56'));
     wp_embed_register_handler('smartideo_youku', '#https?://v\\.youku\\.com/v_show/id_(?<video_id>[a-z0-9_=\\-]+)#i', array($this, 'smartideo_embed_handler_youku'));
     wp_embed_register_handler('smartideo_qq', '#https?://v\\.qq\\.com/(?:[a-z0-9_\\./]+\\?vid=(?<video_id1>[a-z0-9_=\\-]+)|(?:[a-z0-9/]+)/(?<video_id2>[a-z0-9_=\\-]+))#i', array($this, 'smartideo_embed_handler_qq'));
     wp_embed_register_handler('smartideo_sohu', '#https?://my\\.tv\\.sohu\\.com/(?:pl|us)/(?:\\d+)/(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_sohu'));
     wp_embed_register_handler('smartideo_wasu', '#https?://www\\.wasu\\.cn/play/show/id/(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_wasu'));
     wp_embed_register_handler('smartideo_yinyuetai', '#https?://v\\.yinyuetai\\.com/video/(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_yinyuetai'));
     wp_embed_register_handler('smartideo_ku6', '#https?://v\\.ku6\\.com/show/(?<video_id>[a-z0-9\\-_\\.]+).html#i', array($this, 'smartideo_embed_handler_ku6'));
     wp_embed_register_handler('smartideo_letv', '#https?://(?:[a-z0-9/]+\\.)?letv\\.com/(?:[a-z0-9/]+)/(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_letv'));
     wp_embed_register_handler('smartideo_hunantv', '#https?://www\\.hunantv\\.com/(?:[a-z0-9/]+)/(?<video_id>\\d+)\\.html#i', array($this, 'smartideo_embed_handler_hunantv'));
     wp_embed_register_handler('smartideo_acfun', '#https?://www\\.acfun\\.tv/v/ac(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_acfun'));
     wp_embed_register_handler('smartideo_bilibili', '#https?://www\\.bilibili\\.com/video/av(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_bilibili'));
     wp_embed_register_handler('smartideo_youtube', '#https?://www\\.youtube\\.com/watch\\?v=(?<video_id>\\w+)#i', array($this, 'smartideo_embed_handler_youtube'));
     // music
     wp_embed_register_handler('smartideo_music163', '#https?://music\\.163\\.com/\\#/song\\?id=(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_music163'));
     wp_embed_register_handler('smartideo_xiami', '#https?://www\\.xiami\\.com/song/(?<video_id>\\d+)#i', array($this, 'smartideo_embed_handler_xiami'));
 }
Пример #17
0
 /**
  * Register hooks with WP Core
  */
 function __construct()
 {
     self::$instance =& $this;
     //i18n
     add_action('init', array(&$this, 'i18n'));
     //call hook to add admin menu to admin sidebar
     add_action('admin_menu', array(&$this, 'add_menu'));
     add_action('admin_bar_menu', array(&$this, 'admin_bar'), 100);
     //register storify embed handler and callback
     wp_embed_register_handler('storify', $this->permalink_regex, array($this, 'embed_handler'));
     //register plugin with tinyMCE (WYSIWYG editor)
     add_action('admin_init', array(&$this, 'tinymce_register'));
     //enqueue css & js
     add_action('admin_print_styles', array(&$this, 'enqueue_style'));
     add_action('admin_enqueue_scripts', array(&$this, 'enqueue_script'));
     // VIP Customization
     add_action('wp_ajax_storify_dialog', array(&$this, 'dialog_button'));
     //i18n
     add_action('admin_enqueue_scripts', array(&$this, 'localize_scripts'));
     //sanitization
     add_filter('storify_login', array(&$this, 'sanitize_login'));
     add_filter('storify_permalink', array(&$this, 'sanitize_permalink'), 20);
     //callback handler from storify.com
     add_action('admin_title', array(&$this, 'callback_handler'), 999);
     add_filter('template_include', array(&$this, 'callback_redirect'));
     add_filter('storify_permalink', array(&$this, 'maybe_add_http'), 0);
     add_filter('storify_tags', array(&$this, 'hashtag_filter'), 5);
     //iframe URL
     add_filter('storify_iframe_url', array(&$this, 'iframe_url_edit_post_filter'));
     add_filter('storify_iframe_url', array(&$this, 'iframe_url_add_callback_filter'), 100);
     //metabox
     add_action('add_meta_boxes', array(&$this, 'add_metabox'));
     //noscript embeds
     add_filter('storify_embed', array(&$this, 'noscript_link_embed_filter'), 5, 2);
     add_filter('storify_embed', array(&$this, 'noscript_html_embed_filter'), 6, 2);
     //description, title, tags
     add_filter('wp_insert_post_data', array(&$this, 'maybe_add_description'));
     //purge cache on update
     add_action('storify_edit', array(&$this, 'cache_purge'), 10, 1);
     //upgrade DB
     //add_action( 'admin_init', array( &$this, 'upgrade' ) ); // VIP (2012-11-08): disabled as it kills sites with really large numbers of posts
 }
 /**
  * add filters
  */
 public static function filters()
 {
     add_filter('wpv_multiwidget_tab_title', array(__CLASS__, 'multiwidget_tab_title'), 10, 3);
     add_action('wpv_multiwidget_single_title', array(__CLASS__, 'multiwidget_single_title'), 10, 2);
     add_filter('wpv_posts_widget_thumbnail_name', array(__CLASS__, 'posts_widget_thumbnail_name'), 10, 2);
     add_filter('wpv_posts_widget_img_size', array(__CLASS__, 'posts_widget_img_size'), 10, 2);
     add_filter('wpv_column_title', array(__CLASS__, 'column_title'), 10, 2);
     add_filter('excerpt_length', array(__CLASS__, 'excerpt_length'));
     add_filter('excerpt_more', array(__CLASS__, 'excerpt_more'));
     add_filter('wp_title', array(__CLASS__, 'wp_title'));
     remove_filter('the_content', 'li_display_love_link', 100);
     wp_embed_register_handler('wpv-swf', '#https?://[^\\s]+?.swf$#i', array(__CLASS__, 'embed_handler_swf'));
     add_filter('pre_option_page_for_posts', create_function('$value', 'return 0;'));
     add_filter('oembed_dataparse', array(__CLASS__, 'oembed_dataparse'), 90, 3);
     add_filter('nav_menu_css_class', array(__CLASS__, 'nav_menu_css_class'), 10, 3);
     add_filter('nav_menu_css_class', array(__CLASS__, 'nav_menu_css_class'), 11, 3);
     add_action('wpv_body', array(__CLASS__, 'wpv_splash_screen'));
     add_filter('wpcf7_form_elements', array(__CLASS__, 'shortcodes_in_cf7'));
     add_filter('pre_option_wpv_header-layout', array(__CLASS__, 'header_layout'));
 }
 function __construct()
 {
     // Load Localization
     add_action('plugins_loaded', array(&$this, 'lang'));
     // Flash Player URL
     $this->flash_player = plugins_url('3523697345-audio-player.swf', __FILE__);
     // oEmbed Handler for mp3, ogg and wav
     wp_embed_register_handler('html5_audio', '#^http://.+\\.(mp3|ogg|wav)$#i', array(&$this, 'pbwp_embed_handler_html5_audio'));
     // Enqueue Scripts
     //add_action('wp_enqueue_scripts', array(&$this, 'pbwp_embed_handler_html5_audio_jquery'));
     // Register Metabox
     add_action('add_meta_boxes', array(&$this, 'pbwp_register_metabox'));
     // Register Shortcode
     add_action('wp', array(&$this, 'pbwp_register_audio'));
     //add_shortcode('audio', array(&$this, 'pbwp_html5_audio_shortcode'));
     if (is_admin()) {
         add_action('admin_print_scripts', array(&$this, 'pbwp_admin_scripts'));
         add_action('admin_print_styles', array(&$this, 'pbwp_admin_styles'));
     }
 }
	/**
	 * Registers all of the shortcodes that this plugin will handle.
	 *
	 * Metacafe isn't supported by WordPress core but it was easy to add custom
	 * support for it, so it's callback handler is also registered here.
	 *
	 * @since 1.0.0
	 */
	public function add_shortcodes_and_embed_handlers() {
		// These ones need special handling, such as allowing a video ID instead of a full URL.
		add_shortcode( 'youtube', array( $this, 'shortcode_youtube' ) );
		add_shortcode( 'dailymotion', array( $this, 'shortcode_dailymotion' ) );
		add_shortcode( 'vimeo', array( $this, 'shortcode_vimeo' ) );
		add_shortcode( 'metacafe', array( $this, 'shortcode_metacafe' ) );
		wp_embed_register_handler( 'metacafe', '#https?://(www\.)?metacafe\.com/watch/([\d-]+)#i', array( $this, 'embed_handler_metacafe' ) );

		// WordPress supports embedding certain video file types directly.
		if ( function_exists( 'wp_video_shortcode' ) ) {
			add_shortcode( 'flv', array( $this, 'video_shortcode_wrapper' ) );
			add_shortcode( 'wmv', array( $this, 'video_shortcode_wrapper' ) );
		}

		// These services are dead or no longer supported by this plugin due to unpopularity.
		// If a full video URL was passed to the shortcode, then it'll end up as a clickable link.
		add_shortcode( 'googlevideo', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'gvideo', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'stage6', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'veoh', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'viddler', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'blip.tv', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'bliptv', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'ifilm', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'spike', array( $this, 'shortcode_dead_service' ) );
		add_shortcode( 'myspace', array( $this, 'shortcode_dead_service' ) );

		// Run everything else though the code that runs when you paste a URL on its own line.
		// These will end up as clickable links unless another plugin can handle them.
		add_shortcode( 'flickrvideo', array( $GLOBALS['wp_embed'], 'shortcode' ) );
		add_shortcode( 'videofile', array( $GLOBALS['wp_embed'], 'shortcode' ) );
		add_shortcode( 'avi', array( $GLOBALS['wp_embed'], 'shortcode' ) );
		add_shortcode( 'mpeg', array( $GLOBALS['wp_embed'], 'shortcode' ) );
		add_shortcode( 'flash', array( $GLOBALS['wp_embed'], 'shortcode' ) );
		add_shortcode( 'quicktime', array( $GLOBALS['wp_embed'], 'shortcode' ) );
	}
Пример #21
0
/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 *
 * @see wp_embed_register_handler()
 */
function wp_maybe_load_embeds()
{
    /**
     * Filter whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube');
    wp_embed_register_handler('googlevideo', '#http://video\\.google\\.([A-Za-z.]{2,5})/videoplay\\?docid=([\\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    /**
     * Filter the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filter the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}
Пример #22
0
function wpcom_youtube_embed_crazy_url_init()
{
    wp_embed_register_handler('wpcom_youtube_embed_crazy_url', '#https?://(?:www\\.)?(?:youtube.com/(?:v/|playlist|watch[/\\#?])|youtu\\.be/).*#i', 'wpcom_youtube_embed_crazy_url');
}
Пример #23
0
/**
 * Add any new oembed_providers (This is currently a workaround for https://github.com/tatemae/oea/issues/44)
 */
function register_oembed_providers()
{
    $providers = array('openassessments.com' => array('regex' => '#https?://(openassessments\\.com)/assessments/(.*)#i'), 'openassessments.org' => array('regex' => '#https?://(openassessments\\.org)/assessments/(.*)#i'), 'wwwopenassessments.com' => array('regex' => '#https?://(www\\.openassessments\\.com)/assessments/(.*)#i'), 'wwwopenassessments.org' => array('regex' => '#https?://(www.\\openassessments\\.org)/assessments/(.*)#i'), 'oea.herokuapp.com' => array('regex' => '#https?://(oea\\.herokuapp\\.com)/assessments/(.*)#i'));
    wp_embed_register_handler('assessments.lumenlearning.com', '#https?://assessments\\.lumenlearning\\.com/assessments/(.*)#i', '\\Candela\\Utility\\lumen_asmnt_embed_handler');
    foreach ($providers as $id => $info) {
        wp_embed_register_handler($id, $info['regex'], '\\Candela\\Utility\\embed_handler');
    }
}
Пример #24
0
function wpcom_youtube_embed_crazy_url_init()
{
    wp_embed_register_handler('wpcom_youtube_embed_crazy_url', '#http://(www\\.)?youtube.com/v/.*#i', 'wpcom_youtube_embed_crazy_url');
}
Пример #25
0
 * Youku wp_embed handler
 *
 * Embed code last updated:
 *  Wed, 06 Jun 2012 00:36:11 -0400
 *
 * Feel free to submit or correct URL formats here:
 *  http://cn.wordpress.org/contact/
 *
 * @since 3.4.0
 */
function wp_embed_handler_youku($matches, $attr, $url, $rawattr)
{
    $embed = sprintf('<embed src="http://player.youku.com/player.php/sid/%1$s/v.swf" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>', esc_attr($matches['video_id']));
    return apply_filters('embed_youku', $embed, $matches, $attr, $url, $rawattr);
}
wp_embed_register_handler('youku', '#https?://v\\.youku\\.com/v_show/id_(?<video_id>[a-z0-9_=\\-]+)#i', 'wp_embed_handler_youku');
/**
 * Chinese administration screens style - enqueue stylesheet
 *
 * This patch serves as a work-around to fix the font-size and font-style.
 *
 * Submit better CSS rules here:
 *  http://cn.wordpress.org/contact/
 *
 * @since 3.3.0
 */
function zh_cn_l10n_patch_admin_screens_style_enqueue_stylesheet()
{
    wp_register_style('zh-cn-l10n-administration-screens', content_url(WP_DEBUG ? '/languages/zh_CN-administration-screens.dev.css' : '/languages/zh_CN-administration-screens.css'), array('wp-admin'), '20111120');
    wp_enqueue_style('zh-cn-l10n-administration-screens');
}
        $response_body = json_decode($instagram_response['body']);
        if ($response_body_use_cache) {
            // if caching it is short-lived since this is a "Cache-Control: no-cache" resource
            wp_cache_set($cache_key, $response_body, 'instagram_embeds', HOUR_IN_SECONDS + mt_rand(0, HOUR_IN_SECONDS));
        }
    }
    if (!empty($response_body->html)) {
        wp_enqueue_script('jetpack-instagram-embed', plugins_url('js/instagram.js', __FILE__), array('jquery'), false, true);
        // there's a script in the response, which we strip on purpose since it's added by this ^ script
        $ig_embed = preg_replace('@<(script)[^>]*?>.*?</\\1>@si', '', $response_body->html);
        return $ig_embed;
    }
    return '<!-- instagram error: no embed found -->';
}
// filters instagram's username format to the expected format that matches the embed handler
wp_embed_register_handler('jetpack_instagram_alternate_format', '#http(s?)://instagr(\\.am|am\\.com)/([^/]*)/p/([^/]*)#i', 'jetpack_instagram_alternate_format_handler');
function jetpack_instagram_alternate_format_handler($matches, $atts, $url)
{
    $url = esc_url_raw('https://instagram.com/p/' . $matches[4]);
    $matches[0] = $url;
    $matches[3] = $matches[4];
    unset($matches[4]);
    return jetpack_instagram_handler($matches, $atts, $url);
}
// [instagram url="http://instagram.com/p/PSbF9sEIGP/"]
// [instagram url="http://instagram.com/p/PSbF9sEIGP/" width="300"]
add_shortcode('instagram', 'jetpack_shortcode_instagram');
function jetpack_shortcode_instagram($atts)
{
    global $wp_embed;
    if (empty($atts['url'])) {
Пример #27
0
    }
    $vine_size = Jetpack::get_content_width();
    // If the user enters a value for width or height, we ignore the Jetpack::get_content_width()
    if (isset($rawattr['width']) || isset($rawattr['height'])) {
        // 300 is the minimum size that Vine provides for embeds. Lower than that, the postcard embeds looks weird.
        $vine_size = max($max_height, min($attr['width'], $attr['height']));
    }
    if (empty($vine_size)) {
        $vine_size = $max_height;
    }
    $url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type;
    $vine_html = sprintf('<span class="embed-vine" style="display: block;"><iframe class="vine-embed" src="%s" width="%s" height="%s" frameborder="0"></iframe></span>', esc_url($url), (int) $vine_size, (int) $vine_size);
    if ($vine_flag_embedded_script !== true) {
        $vine_html .= '<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>';
        $vine_flag_embedded_script = true;
    }
    return $vine_html;
}
wp_embed_register_handler('jetpack_vine', '#https?://vine.co/v/([a-z0-9]+).*#i', 'vine_embed_video');
function vine_shortcode($atts)
{
    global $wp_embed;
    if (empty($atts['url'])) {
        return '';
    }
    if (!preg_match('#https?://vine.co/v/([a-z0-9]+).*#i', $atts['url'])) {
        return '';
    }
    return $wp_embed->shortcode($atts, $atts['url']);
}
add_shortcode('vine', 'vine_shortcode');
Пример #28
0
define('JETPACK_FACEBOOK_PHOTO_EMBED_REGEX', '#^https?://(www.)?facebook\\.com/photo.php\\?([^\\s]+)#');
define('JETPACK_FACEBOOK_PHOTO_ALTERNATE_EMBED_REGEX', '#^https?://(www.)?facebook\\.com/([^/]+)/photos/([^/]+)?#');
define('JETPACK_FACEBOOK_VIDEO_EMBED_REGEX', '#^https?://(www.)?facebook\\.com/video.php\\?([^\\s]+)#');
define('JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX', '#^https?://(www.)?facebook\\.com/([^/]+)/videos/([^/]+)?#');
// Example URL: https://www.facebook.com/VenusWilliams/posts/10151647007373076
wp_embed_register_handler('facebook', JETPACK_FACEBOOK_EMBED_REGEX, 'jetpack_facebook_embed_handler');
// Example URL: https://www.facebook.com/permalink.php?id=222622504529111&story_fbid=559431180743788
wp_embed_register_handler('facebook-alternate', JETPACK_FACEBOOK_ALTERNATE_EMBED_REGEX, 'jetpack_facebook_embed_handler');
// Photos are handled on a different endpoint; e.g. https://www.facebook.com/photo.php?fbid=10151609960150073&set=a.398410140072.163165.106666030072&type=1
wp_embed_register_handler('facebook-photo', JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, 'jetpack_facebook_embed_handler');
// Photos (from pages for example) can be at
wp_embed_register_handler('facebook-alternate-photo', JETPACK_FACEBOOK_PHOTO_ALTERNATE_EMBED_REGEX, 'jetpack_facebook_embed_handler');
// Videos e.g. https://www.facebook.com/video.php?v=772471122790796
wp_embed_register_handler('facebook-video', JETPACK_FACEBOOK_VIDEO_EMBED_REGEX, 'jetpack_facebook_embed_handler');
// Videos  https://www.facebook.com/WhiteHouse/videos/10153398464269238/
wp_embed_register_handler('facebook-alternate-video', JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, 'jetpack_facebook_embed_handler');
function jetpack_facebook_embed_handler($matches, $attr, $url)
{
    if (false !== strpos($url, 'video.php') || false !== strpos($url, '/videos/')) {
        $embed = sprintf('<div class="fb-video" data-allowfullscreen="true" data-href="%s"></div>', esc_url($url));
    } else {
        $embed = sprintf('<fb:post href="%s"></fb:post>', esc_url($url));
    }
    // since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe
    if (defined('DOING_AJAX') && DOING_AJAX && !empty($_POST['action']) && 'parse-embed' == $_POST['action']) {
        return $embed . '<script src="//connect.facebook.net/en_US/all.js#xfbml=1"></script>';
    } else {
        wp_enqueue_script('jetpack-facebook-embed', plugins_url('js/facebook.js', __FILE__), array('jquery'), null, true);
        return $embed;
    }
}
Пример #29
0
            // Since we support Instagram via oEmbed, we simply leave a link on a line by itself.
            $replace_regex = sprintf('#\\s*%s\\s*#', preg_quote($match[0], '#'));
            $url = esc_url($url_matches[0]);
            $content = preg_replace($replace_regex, sprintf("\n\n%s\n\n", $url), $content);
            do_action('jetpack_embed_to_shortcode', 'instagram', $url);
        }
    }
    return $content;
}
add_filter('pre_kses', 'jetpack_instagram_embed_reversal');
/**
 * Instagram
 */
wp_oembed_remove_provider('#http://instagr(\\.am|am\\.com)/p/.*#i');
// remove core's oEmbed support so we can override
wp_embed_register_handler('jetpack_instagram', '#http(s?)://instagr(\\.am|am\\.com)/p/([^/]*)#i', 'jetpack_instagram_handler');
function jetpack_instagram_handler($matches, $atts, $url)
{
    global $content_width;
    static $did_script;
    // keep a copy of the passed-in URL since it's modified below
    $passed_url = $url;
    $max_width = 698;
    $min_width = 320;
    if (is_feed()) {
        $media_url = sprintf('http://instagr.am/p/%s/media/?size=l', $matches[2]);
        return sprintf('<a href="%s" title="%s"><img src="%s" alt="Instagram Photo" /></a>', esc_url($url), esc_attr__('View on Instagram', 'jetpack'), esc_url($media_url));
    }
    $atts = shortcode_atts(array('width' => isset($content_width) ? $content_width : $max_width, 'hidecaption' => false), $atts);
    $atts['width'] = absint($atts['width']);
    if ($atts['width'] > $max_width || $min_width > $atts['width']) {
Пример #30
0
<?php

/**
 * Facebook embeds
 */

define( 'JETPACK_FACEBOOK_EMBED_REGEX', '#^https?://(www.)?facebook\.com/([^/]+)/posts/([^/]+)?#' );
define( 'JETPACK_FACEBOOK_PHOTO_EMBED_REGEX', '#^https?://(www.)?facebook\.com/photo.php\?([^\s]+)#' );

// Example URL: https://www.facebook.com/VenusWilliams/posts/10151647007373076 
wp_embed_register_handler( 'facebook', JETPACK_FACEBOOK_EMBED_REGEX, 'jetpack_facebook_embed_handler' );
// Photos are handled on a different endpoint; e.g. https://www.facebook.com/photo.php?fbid=10151609960150073&set=a.398410140072.163165.106666030072&type=1 
wp_embed_register_handler( 'facebook-photo', JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, 'jetpack_facebook_embed_handler' );

function jetpack_facebook_embed_handler( $matches, $attr, $url ) {
	static $did_script;

	if ( ! $did_script ) {
		$did_script = true;
		add_action( 'wp_footer', 'jetpack_facebook_add_script' ); 
	}

	return sprintf( '<fb:post href="%s"></fb:post>', esc_url( $url ) );
}

function jetpack_facebook_add_script() {
	?>
	<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, "script", "facebook-jssdk"));</script>
	<?php
}