|
@@ -1,10 +1,23 @@
|
|
|
<?php
|
|
|
-// ############### require ################## //
|
|
|
|
|
|
+/*************************************************
|
|
|
+// ############### parent theme ################## //
|
|
|
+**************************************************/
|
|
|
+add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
|
|
|
+function enqueue_parent_styles() {
|
|
|
+ wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############### require ################## //
|
|
|
+**************************************************/
|
|
|
//require get_stylesheet_directory() . '/inc/cust-func.php';
|
|
|
|
|
|
-// ############### wp_head ################## //
|
|
|
|
|
|
+/*************************************************
|
|
|
+// ############### wp_head ################## //
|
|
|
+**************************************************/
|
|
|
remove_action('wp_head', 'index_rel_link' );
|
|
|
remove_action('wp_head', 'rel_canonical');
|
|
|
remove_action('wp_head', 'start_post_rel_link', 10);
|
|
@@ -36,7 +49,10 @@ function dwp_disable_x_pingback( $headers ) {
|
|
|
return $headers;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/*************************************************
|
|
|
// ############### Emojis ################## //
|
|
|
+**************************************************/
|
|
|
function dwp_disable_emojis() {
|
|
|
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
|
|
|
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
|
|
@@ -45,19 +61,439 @@ function dwp_disable_emojis() {
|
|
|
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
|
|
|
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
|
|
|
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
|
|
|
- add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
|
|
|
+ //add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
|
|
|
add_filter( 'emoji_svg_url', '__return_false' );
|
|
|
}
|
|
|
add_action( 'init', 'dwp_disable_emojis' );
|
|
|
|
|
|
-// ############### Emojis ################## //
|
|
|
-add_action( 'admin_menu', 'tc_remove_tools', 99 );
|
|
|
-function tc_remove_tools() {
|
|
|
- global $menu;
|
|
|
- global $submenu;
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############ style-admin.css ############## //
|
|
|
+**************************************************/
|
|
|
+add_action('admin_enqueue_scripts', 'dwp_admin_theme_style');
|
|
|
+function dwp_admin_theme_style() {
|
|
|
+ wp_enqueue_style('dwp-theme', get_stylesheet_directory_uri() . '/style-admin.css');
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############## Admin pages ################ //
|
|
|
+**************************************************/
|
|
|
+add_action( 'admin_menu', 'dwp_remove_admin_pages', 99 );
|
|
|
+function dwp_remove_admin_pages() {
|
|
|
+ /*
|
|
|
remove_menu_page( 'tools.php' );
|
|
|
- //remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
|
|
|
+ remove_menu_page( 'edit.php?post_type=page' );
|
|
|
+ remove_menu_page( 'edit.php?post_type=portfolio' );
|
|
|
+ remove_menu_page( 'edit-comments.php' );
|
|
|
+ remove_menu_page( 'edit.php' );
|
|
|
+ remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
|
|
|
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
|
|
|
- remove_menu_page('edit-comments.php');
|
|
|
- remove_submenu_page('admin.php', 'admin.php?page=newsletter_main_welcome');
|
|
|
+ remove_menu_page( 'upload.php' );
|
|
|
+ remove_menu_page( 'themes.php' );
|
|
|
+ remove_menu_page( 'plugins.php' );
|
|
|
+ remove_menu_page( 'users.php' );
|
|
|
+ remove_menu_page( 'profile.php' );
|
|
|
+ remove_menu_page( 'options-general.php' );
|
|
|
+ */
|
|
|
+}
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ######### email from:/reply-to ############# //
|
|
|
+**************************************************/
|
|
|
+add_filter('wp_mail_from', 'dwp_fromemail');
|
|
|
+function dwp_fromemail($email) {
|
|
|
+ $wpfrom = get_option('admin_email');
|
|
|
+ return $wpfrom;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ######### rm 'WordPress' admin title ####### //
|
|
|
+**************************************************/
|
|
|
+add_filter('admin_title', 'dwp_admin_title', 10, 2);
|
|
|
+function dwp_admin_title($admin_title, $title) {
|
|
|
+ return get_bloginfo('name').' - '.$title;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############## login/out ################### //
|
|
|
+**************************************************/
|
|
|
+add_action('wp_logout','dwp_redirect_after_logout');
|
|
|
+function dwp_redirect_after_logout(){
|
|
|
+ wp_safe_redirect( home_url() );
|
|
|
+ exit();
|
|
|
+}
|
|
|
+add_filter( 'login_headertext', 'dwp_login_title' );
|
|
|
+function dwp_login_title() {
|
|
|
+ return get_option( 'blogname' );
|
|
|
+}
|
|
|
+add_filter( 'login_headerurl', 'dwp_login_url' );
|
|
|
+function dwp_login_url($url) {
|
|
|
+ return home_url();
|
|
|
+}
|
|
|
+//add_filter( 'login_redirect', 'dwp_login_redirect', 10, 3 );
|
|
|
+//function dwp_login_redirect( $redirect_to, $request, $user ){
|
|
|
+// return home_url();
|
|
|
+//}
|
|
|
+add_action( 'login_enqueue_scripts', 'dwp_login_logo' );
|
|
|
+function dwp_login_logo() { ?>
|
|
|
+ <style type="text/css">
|
|
|
+ body.login {
|
|
|
+ background-color: #333;
|
|
|
+ }
|
|
|
+ #login h1 a, .login h1 a {
|
|
|
+ background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/img/logo.png);
|
|
|
+ height:130px;
|
|
|
+ width:320px;
|
|
|
+ background-size: 320px 130px;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ padding-bottom: 10px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+<?php }
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############ admin menu order ############## //
|
|
|
+**************************************************/
|
|
|
+add_filter( 'custom_menu_order', '__return_true' );
|
|
|
+add_filter( 'menu_order', 'dwp_change_menu_order' );
|
|
|
+function dwp_change_menu_order( $menu_order ) {
|
|
|
+ return array(
|
|
|
+ 'index.php',
|
|
|
+ 'edit.php',
|
|
|
+ 'edit.php?post_type=page',
|
|
|
+ 'upload.php',
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############# Admin Bar ################## //
|
|
|
+**************************************************/
|
|
|
+add_filter('show_admin_bar', '__return_false');
|
|
|
+add_filter('show_recent_comments_widget_style', function() { return false; });
|
|
|
+
|
|
|
+add_action( 'admin_bar_menu', 'dwp_remove_adminbar', 999 );
|
|
|
+function dwp_remove_adminbar( $wp_admin_bar ) {
|
|
|
+ $wp_admin_bar->remove_node( 'wp-logo' );
|
|
|
+ $wp_admin_bar->remove_menu( 'edit' );
|
|
|
+ $wp_admin_bar->remove_menu( 'new-user' );
|
|
|
+ $wp_admin_bar->remove_menu( 'new-post' );
|
|
|
+ $wp_admin_bar->remove_menu( 'new-page' );
|
|
|
+ $wp_admin_bar->remove_node( 'new-media' );
|
|
|
+ $wp_admin_bar->remove_menu( 'edit-profile' );
|
|
|
+ $wp_admin_bar->remove_menu( 'comments' );
|
|
|
+}
|
|
|
+function dwp_remove_new_content(){
|
|
|
+ global $wp_admin_bar;
|
|
|
+ $wp_admin_bar->remove_menu( 'new-content' );
|
|
|
+}
|
|
|
+add_action( 'wp_before_admin_bar_render', 'dwp_remove_new_content' );
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############ admin footer ############## //
|
|
|
+**************************************************/
|
|
|
+add_filter('admin_footer_text', '__return_empty_string', 1000);
|
|
|
+add_filter('update_footer', '__return_empty_string', 1000);
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############ dashboard items ################ //
|
|
|
+**************************************************/
|
|
|
+remove_action('welcome_panel', 'wp_welcome_panel');
|
|
|
+add_filter('screen_options_show_screen', '__return_false');
|
|
|
+add_action('admin_head', 'dwp_remove_help_tabs');
|
|
|
+function dwp_remove_help_tabs() {
|
|
|
+ $screen = get_current_screen();
|
|
|
+ $screen->remove_help_tabs();
|
|
|
+}
|
|
|
+add_action( 'admin_init', 'dwp_remove_dashboard_meta' );
|
|
|
+function dwp_remove_dashboard_meta() {
|
|
|
+ remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal' );
|
|
|
+ remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
|
|
|
+ remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
|
|
|
+ remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
|
|
|
+ remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
|
|
|
+ remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
|
|
|
+ remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ####### comments on attachments ############# //
|
|
|
+**************************************************/
|
|
|
+add_action( 'pre_comment_on_post', 'dwp_remove_comments_from_attachments', 10, 2 );
|
|
|
+function dwp_remove_comments_from_attachments( $open, $post_id ){
|
|
|
+ return ( 'attachment' == get_post_type( $post_id ) ) ? false : $open;
|
|
|
+}
|
|
|
+add_filter( 'comments_open', 'dwp_filter_media_comment_status', 10 , 2 );
|
|
|
+function dwp_filter_media_comment_status( $open, $post_id ) {
|
|
|
+ $post = get_post( $post_id );
|
|
|
+ if( $post->post_type == 'attachment' ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return $open;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ####### menus for logged in/out ############# //
|
|
|
+ create two menus named 'logged-in' & 'logged-out
|
|
|
+ in top-navigation location of theme
|
|
|
+**************************************************/
|
|
|
+add_filter( 'wp_nav_menu_args', 'dwp_nav_menu_args' );
|
|
|
+function dwp_nav_menu_args( $args = '' ) {
|
|
|
+ if( is_user_logged_in() ) {
|
|
|
+ if( 'top-navigation' == $args['theme_location'] ) {
|
|
|
+ $args['menu'] = 'logged-in';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if( 'top-navigation' == $args['theme_location'] ) {
|
|
|
+ $args['menu'] = 'logged-out';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $args;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############ user last login ################ //
|
|
|
+**************************************************/
|
|
|
+add_action( 'wp_login', 'dwp_login_timestamp', 20, 2 );
|
|
|
+function dwp_login_timestamp( $user_login, $user ) {
|
|
|
+ update_user_meta( $user->ID, 'last_login', time() );
|
|
|
+}
|
|
|
+add_filter( 'manage_users_columns', 'dwp_user_last_login_column' );
|
|
|
+function dwp_user_last_login_column( $columns ) {
|
|
|
+ $columns['last_login'] = 'Last Login';
|
|
|
+ return $columns;
|
|
|
+}
|
|
|
+add_filter( 'manage_users_custom_column', 'dwp_last_login_column', 10, 3 );
|
|
|
+function dwp_last_login_column( $output, $column_id, $user_id ){
|
|
|
+ if( $column_id == 'last_login' ) {
|
|
|
+ $last_login = get_user_meta( $user_id, 'last_login', true );
|
|
|
+ $date_format = 'j M, Y';
|
|
|
+ $output = $last_login ? date( $date_format, $last_login ) : '-';
|
|
|
+ }
|
|
|
+ return $output;
|
|
|
+}
|
|
|
+add_filter( 'manage_users_sortable_columns', 'dwp_sortable_columns' );
|
|
|
+function dwp_sortable_columns( $columns ) {
|
|
|
+ return wp_parse_args( array(
|
|
|
+ 'last_login' => 'last_login'
|
|
|
+ ), $columns );
|
|
|
+}
|
|
|
+add_action( 'pre_get_users', 'dwp_sort_last_login_column' );
|
|
|
+function dwp_sort_last_login_column( $query ) {
|
|
|
+ if( !is_admin() ) {
|
|
|
+ return $query;
|
|
|
+ }
|
|
|
+ $screen = get_current_screen();
|
|
|
+ if( isset( $screen->id ) && $screen->id !== 'users' ) {
|
|
|
+ return $query;
|
|
|
+ }
|
|
|
+ if( isset( $_GET[ 'orderby' ] ) && $_GET[ 'orderby' ] == 'last_login' ) {
|
|
|
+ $query->query_vars['meta_key'] = 'last_login';
|
|
|
+ $query->query_vars['orderby'] = 'meta_value';
|
|
|
+ }
|
|
|
+ return $query;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ########## Howdy email/adminbar ############# //
|
|
|
+**************************************************/
|
|
|
+add_filter( 'gettext', 'dwp_change_howdy_text', 10, 2 );
|
|
|
+function dwp_change_howdy_text( $translation, $original ) {
|
|
|
+ if( 'Howdy, %1$s' == $original )
|
|
|
+ $translation = '%1$s';
|
|
|
+ return $translation;
|
|
|
+}
|
|
|
+add_filter( 'admin_bar_menu', 'dwp_replace_howdy', 25 );
|
|
|
+function dwp_replace_howdy( $wp_admin_bar ) {
|
|
|
+ $my_account = $wp_admin_bar->get_node('my-account');
|
|
|
+ $newtext = str_replace( 'Howdy,', '', $my_account->title );
|
|
|
+ $wp_admin_bar->add_node( array(
|
|
|
+ 'id' => 'my-account',
|
|
|
+ 'title' => $newtext,
|
|
|
+ ) );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############### user profile ################ //
|
|
|
+**************************************************/
|
|
|
+if(is_admin()){
|
|
|
+ remove_action("admin_color_scheme_picker", "admin_color_scheme_picker");
|
|
|
+}
|
|
|
+add_action( 'personal_options_update', 'dwp_save_extra_user_profile_fields' );
|
|
|
+add_action( 'edit_user_profile_update', 'dwp_save_extra_user_profile_fields' );
|
|
|
+
|
|
|
+add_action( 'show_user_profile', 'dwp_extra_user_profile_fields' );
|
|
|
+add_action( 'edit_user_profile', 'dwp_extra_user_profile_fields' );
|
|
|
+
|
|
|
+function dwp_extra_user_profile_fields( $user ) { ?>
|
|
|
+ <br>
|
|
|
+ <h3><?php _e("User Information", "blank"); ?></h3>
|
|
|
+ <p>This information is useful for adminstrative purposes</p>
|
|
|
+
|
|
|
+ <table class="form-table">
|
|
|
+ <tr>
|
|
|
+ <th><label for="address"><?php _e("Phone"); ?></label></th>
|
|
|
+ <td>
|
|
|
+ <input type="text" name="phone" id="phone" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
|
+ <span class="description"><?php _e("Please enter your phone number."); ?></span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <th><label for="address"><?php _e("Address"); ?></label></th>
|
|
|
+ <td>
|
|
|
+ <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
|
+ <span class="description"><?php _e("Please enter your address."); ?></span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <th><label for="city"><?php _e("City"); ?></label></th>
|
|
|
+ <td>
|
|
|
+ <input type="text" name="city" id="city" value="<?php echo esc_attr( get_the_author_meta( 'city', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
|
+ <span class="description"><?php _e("Please enter your city."); ?></span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <th><label for="postalcode"><?php _e("Postal Code"); ?></label></th>
|
|
|
+ <td>
|
|
|
+ <input type="text" name="postalcode" id="postalcode" value="<?php echo esc_attr( get_the_author_meta( 'postalcode', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
|
+ <span class="description"><?php _e("Please enter your postal code."); ?></span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+ <br>
|
|
|
+ <h3><?php _e("User Accounts", "blank"); ?></h3>
|
|
|
+ <p>This information is useful for the OpenGraph Protocol</p>
|
|
|
+ <tr>
|
|
|
+ <table class="form-table">
|
|
|
+ <th><label for="postalcode"><?php _e("Facebook Username"); ?></label></th>
|
|
|
+ <td>
|
|
|
+ <input type="text" name="facebook-username" id="facebook-username" value="<?php echo esc_attr( get_the_author_meta( 'facebook-username', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
|
+ <span class="description"><?php _e("Please enter your Facebook username."); ?></span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <th><label for="postalcode"><?php _e("Twitter Username"); ?></label></th>
|
|
|
+ <td>
|
|
|
+ <input type="text" name="twitter-username" id="twitter-username" value="<?php echo esc_attr( get_the_author_meta( 'twitter-username', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
|
+ <span class="description"><?php _e("Please enter your Twitter username."); ?></span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+<?php }
|
|
|
+
|
|
|
+add_action( 'personal_options_update', 'dwp_save_extra_user_profile_fields' );
|
|
|
+add_action( 'edit_user_profile_update', 'dwp_save_extra_user_profile_fields' );
|
|
|
+
|
|
|
+function dwp_save_extra_user_profile_fields( $user_id ) {
|
|
|
+ if ( !current_user_can( 'edit_user', $user_id ) ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ update_user_meta( $user_id, 'phone', $_POST['phone'] );
|
|
|
+ update_user_meta( $user_id, 'address', $_POST['address'] );
|
|
|
+ update_user_meta( $user_id, 'city', $_POST['city'] );
|
|
|
+ update_user_meta( $user_id, 'postalcode', $_POST['postalcode'] );
|
|
|
+ update_user_meta( $user_id, 'facebook-username', $_POST['facebook-username'] );
|
|
|
+ update_user_meta( $user_id, 'twitter-username', $_POST['twitter-username'] );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*************************************************
|
|
|
+// ############# OpenGraph meta ################ //
|
|
|
+**************************************************/
|
|
|
+add_filter('language_attributes', 'dwp_doctype_opengraph');
|
|
|
+function dwp_doctype_opengraph($output) {
|
|
|
+ return $output . '
|
|
|
+ xmlns:og="http://opengraphprotocol.org/schema/"
|
|
|
+ xmlns:fb="http://www.facebook.com/2008/fbml"';
|
|
|
+}
|
|
|
+add_action('wp_head', 'dwp_opengraph', 5);
|
|
|
+function dwp_opengraph() {
|
|
|
+ global $post;
|
|
|
+ if (is_single()) {
|
|
|
+ if (has_post_thumbnail($post->ID)) {
|
|
|
+ $img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'full'); $img_src = $img_src[0];
|
|
|
+ } elseif ( metadata_exists( 'post', get_the_ID(), 'featured_image_url' ) ){
|
|
|
+ $img_src = get_post_meta( get_the_ID(), 'featured_image_url', true );
|
|
|
+ } else {
|
|
|
+ $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg';
|
|
|
+ }
|
|
|
+ if($excerpt = $post->post_excerpt) {
|
|
|
+ $excerpt = strip_tags($post->post_excerpt);
|
|
|
+ $excerpt = str_replace("", "'", $excerpt);
|
|
|
+ } else {
|
|
|
+ $excerpt = get_bloginfo('description');
|
|
|
+ }
|
|
|
+?>
|
|
|
+ <meta property="og:title" content="<?php echo the_title(); ?>"/>
|
|
|
+ <meta property="og:description" content="<?php echo $excerpt; ?>"/>
|
|
|
+ <meta property="og:type" content="article"/>
|
|
|
+ <meta property="og:url" content="<?php echo the_permalink(); ?>"/>
|
|
|
+ <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/>
|
|
|
+ <meta property="og:image" content="<?php echo $img_src; ?>"/>
|
|
|
+ <meta property="fb:app_id" content="203136806559589" />
|
|
|
+ <meta name="twitter:site" content="@<?php echo get_user_meta( get_current_user_id(), 'twitter-username', true );?>">
|
|
|
+ <meta name="twitter:creator" content="@<?php echo get_user_meta( get_current_user_id(), 'twitter-username', true );?>">
|
|
|
+ <meta name="twitter:title" content="<?php echo the_title(); ?>">
|
|
|
+ <meta name="twitter:description" content="<?php echo $excerpt; ?>">
|
|
|
+ <meta name="twitter:image" content="<?php echo $img_src; ?>">
|
|
|
+<?php
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
|
|
|
+ $media_url = get_post_meta( get_the_ID(), 'media', true );
|
|
|
+ $media = get_media_embedded_in_content( $content );
|
|
|
+ if( !empty($media) ) {
|
|
|
+ $video_url = $media[0];
|
|
|
+ ?>
|
|
|
+ <meta property="og:video" content="<?php echo $media_url; ?>" />
|
|
|
+ <meta property="og:video:secure_url" content="<?php echo $media_url; ?>" />
|
|
|
+ <meta property="og:video:width" content="1280" />
|
|
|
+ <meta property="og:video:height" content="720" />
|
|
|
+ <meta property="og:video:type" content="video/mp4" />
|
|
|
+ <meta name="twitter:card" content="player">
|
|
|
+ <meta name="twitter:player" content="<?php echo get_permalink();?>container/" />
|
|
|
+ <meta name="twitter:player:width" content="1280" />
|
|
|
+ <meta name="twitter:player:height" content="720" />
|
|
|
+ <meta name="twitter:player:stream" content="<?php echo $media_url; ?>" />
|
|
|
+ <meta name="twitter:player:stream:content_type" content="video/mp4" />
|
|
|
+<?php
|
|
|
+ } else {
|
|
|
+?>
|
|
|
+ <meta name="twitter:card" content="summary_large_image">
|
|
|
+<?php
|
|
|
+ }
|
|
|
+}
|
|
|
+add_action( 'init', 'dwp_read_container_endpoint' );
|
|
|
+function dwp_read_container_endpoint(){
|
|
|
+ add_rewrite_endpoint( 'container', EP_PERMALINK);
|
|
|
+}
|
|
|
+add_filter( 'single_template', 'dwp_read_container_template' );
|
|
|
+function dwp_read_container_template( $template = '' ) {
|
|
|
+ global $wp_query;
|
|
|
+ if( ! array_key_exists( 'container', $wp_query->query_vars ) ) return $template;
|
|
|
+ $template = locate_template( 'single-container.php' );
|
|
|
+ return $template;
|
|
|
+}
|
|
|
+add_shortcode( 'video', 'dwp_video_embed' );
|
|
|
+function dwp_video_embed( $attr, $content='' ) {
|
|
|
+ if ( ! isset( $attr['poster'] ) && has_post_thumbnail() ) {
|
|
|
+ $poster = get_post_meta( get_the_ID(), 'media-poster', true );
|
|
|
+ $attr['poster'] = $poster;
|
|
|
+ }
|
|
|
+ return wp_video_shortcode( $attr, $content );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|