Sindbad~EG File Manager
<?php
/*
* Security : blocking direct access
* Source : http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");
/*
* Noindex duplicates – author, date archive, pagination, tags, 404, search
*
*/
function mwp_seo_noindex_paged_archive() {
if (mwp_option('noindex-archives') == 0) return;
if ( is_home() && is_paged() || is_archive() && is_paged() || is_tag() || is_author() || is_date() || is_404() || is_search() )
echo '<meta name="robots" content="noindex,nofollow" />';
}
add_action('wp_head', 'mwp_seo_noindex_paged_archive', 0);
/*
* Redirect attachment URLs to the attachment itself
* https://gist.github.com/chrisguitarguy/1177112
*
*/
function mwp_seo_disable_attachment() {
if (mwp_option('disable-post-attachment') == 0) return;
if( ! is_attachment() ) return;
global $post;
if( empty( $post ) ) $post = get_queried_object();
$link = get_permalink( $post->post_parent );
wp_redirect( $link, '301' );
exit();
}
add_action( 'template_redirect', 'mwp_seo_disable_attachment' );
/*
=============================================================
+ +
+ +
+ THUMBNAIL +
+ +
+ +
=============================================================
*/
/*!
* Function name : SEO Image Helper
* Function Description : display image based on thumbnail type from MWP-Panel
* Author Name : Mouad Achemli
* Function Source : http://www.mwordpress.net
* Note : this function is important do not remove from here
*
*/
function mwp_seo_image($post_id) {
$width = 772;
$height = 432;
$thumb_type = mwp_option('thumbnail-type');
if ($thumb_type == 1) {
$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
if(!empty($image_url)) {
$image = $image_url;
} else {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
$image = $thumbnail['0'];
}
if (!empty($image)) {
return $image;
} else {
return mwp_thumb_size_default_src();
}
}
elseif ($thumb_type == 2) {
return image_post_resized_src(mwp_option('custom-field-name'));
}
elseif ($thumb_type == 3) {
$get_image_url = getImage('1');
if (!empty($get_image_url)) {
return $get_image_url;
} else {
return mwp_thumb_size_default_src();
}
}
elseif($thumb_type == 4) {
return getImage_external('1');
}
elseif($thumb_type == 5) {
$get_image_url = get_first_thumbnail();
$check_image = parse_url($get_image_url, PHP_URL_HOST);
$check_local = parse_url(site_url(), PHP_URL_HOST);
if ($check_image == $check_local) {
return $get_image_url;
} else {
return mwp_thumb_size_default_src();
}
}
elseif($thumb_type == 6) {
$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
if(!empty($image_url)) {
$image = $image_url;
} else {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
$image = $thumbnail['0'];
}
if (!empty($image)) {
return get_template_directory_uri().'/resize.php?src='.$image.'&w='.$width.'&h='.$height.'&zc=0&q=100';
} else {
return mwp_thumb_size_default_src();
}
}
elseif($thumb_type == 7) {
$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
if(!empty($image_url)) {
$image = $image_url;
} else {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
$image = $thumbnail['0'];
}
if (!empty($image)) {
return home_url().'/media/resizer/'.$width.'x'.$height.'/r/'.remove_http($image);
} else {
return mwp_thumb_size_default_src();
}
}
elseif ($thumb_type == 8) {
$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
if(!empty($image_url)) {
$image = $image_url;
} else {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
$image = $thumbnail['0'];
}
if (!empty($image)) {
$param = array(
'resize' => $width.','.$height,
'quality' => '100',
'fit' => ''
);
return jetpack_photon_url( $image, $param );
} else {
return mwp_thumb_size_default_src();
}
}
elseif ($thumb_type == 9) {
$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
if(!empty($image_url)) {
$image = $image_url;
} else {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
$image = $thumbnail['0'];
}
if (!empty($image)) {
return $image;
} else {
return mwp_thumb_size_default_src();
}
}
}
/*!
* Function name : SEO Image Helper [ --> Video <--- ]
* Function Description : check if post has images from external source
* : like youtube, vimeo, dailymotion, facebook
* Author Name : Mouad Achemli
* Function Source : http://www.mwordpress.net
* Note : this function is important do not remove from here
*
*/
function mwp_seo_image_video($post_id, $width, $height) {
if (mwp_option('thumbnail-vyd') == 0 || has_post_thumbnail() ) {
return mwp_seo_image($post_id);
} else {
// New custom field Youtube & Vimeo & Dailymotion
$key_exists_yt = metadata_exists( 'post', $post_id, 'mwp_yt_id' );
$key_exists_vi = metadata_exists( 'post', $post_id, 'mwp_vi_thumbnail' );
$key_exists_dm = metadata_exists( 'post', $post_id, 'mwp_dm_thumbnail' );
$key_exists_fb = metadata_exists( 'post', $post_id, 'mwp_fb_id' );
// Get New custom field value (Video ID)
$check_y = get_post_meta($post_id, 'mwp_yt_id' , true);
$check_v = get_post_meta($post_id, 'mwp_vi_thumbnail' , true);
$check_d = get_post_meta($post_id, 'mwp_dm_thumbnail' , true);
$check_f = get_post_meta($post_id, 'mwp_fb_id' , true);
if ($key_exists_yt == true && !empty($check_y)) {
return "https://i1.ytimg.com/vi/$check_y/hqdefault.jpg";
} elseif ($key_exists_vi == true && !empty($check_v)) {
return $check_v;
} elseif ($key_exists_dm == true && !empty($check_d)) {
return $check_d;
} elseif ($key_exists_fb == true && !empty($check_f)) {
return $check_f;
} else {
return mwp_thumb_size_default_src();
}
}
}
/*!
* Function name : Social Image Helper
* Function Description : display image from Post Custom field
* Author Name : Mouad Achemli
* Function Source : http://www.mwordpress.net
* Note : this function is important do not remove from here
*
*/
function mwp_social_image($postid) {
$data = get_post_meta($postid, 'mwp_social_image' , true);
if (!empty($data)) {
$image = $data;
} else {
$videos_ids = mwp_option('category-videos');
if (!empty($videos_ids) && in_category($videos_ids)) {
$image = mwp_seo_image_video($postid, 772, 433);
} else {
$image = mwp_seo_image($postid);
}
}
return $image;
}
/*
=============================================================
+ +
+ +
+ GENERAL +
+ +
+ +
=============================================================
*/
/*!
* Returns a post's modified date, formatted according to $format.
* @uses the_modified_time()
*
* @param int $post_id Post ID.
* @param string $format Date format Default: "F j, Y".
* @source : http://wordpress.stackexchange.com/a/115044/40961
* Note : this function is important do not remove from here
*/
function seo_modified_time($format, $post_id){
$modified_time = get_the_modified_time($format, $post_id);
return $modified_time;
}
/*!
* Returns a post's publish date, formatted according to $format.
* @uses get_the_date
*
* @param int $post_id Post ID.
* @param string $format Date format Default: "F j, Y".
* Note : this function is important do not remove from here
*/
function seo_publish_date($format, $post_id ){
$publish_date = get_the_date($format, $post_id);
return $publish_date;
}
/*!
* Get Permalink on Custom Post Type Archive or Taxonomy pages
* @source : http://isabelcastillo.com/?p=2072
* Note : this function is important do not remove from here
*/
function g_permalink_archive() {
if ( is_tax() ) {
$permalink = get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
} elseif( is_post_type_archive() ) {
$permalink = get_post_type_archive_link( get_query_var('post_type') );
} else {
$permalink = get_permalink();
}
return $permalink;
}
// If you have the opengraph plugin running alongside jetpack, we assume you'd
// rather use our opengraph support, so disable jetpack's opengraph functionality.
add_filter( 'jetpack_enable_opengraph', '__return_false' );
add_filter( 'jetpack_enable_open_graph', '__return_false' );
/*
=============================================================
+ +
+ +
+ AUTHOR +
+ +
+ +
=============================================================
*/
/*!
* User Social URL
* get social links from user contact methode
* @author : Achemli Mouad
*/
function seo_author_social_url($source, $author_id) {
switch ($source) {
case 'facebook' :
$facebook_url = get_the_author_meta('facebook', $author_id);
if (!empty($facebook_url)) {
$social_url = $facebook_url;
} else {
$social_url = mwp_option('facebook-author');
}
break;
case 'twitter' :
$twitter_url = get_the_author_meta('twitter', $author_id);
if (!empty($twitter_url)) {
$social_url = $twitter_url;
} else {
$social_url = mwp_option('twitter-link');
}
break;
case 'google' :
$google_url = get_the_author_meta('googleplus', $author_id);
if (!empty($google_url)) {
$social_url = $google_url;
} else {
$social_url = mwp_option('seo-publisher');
}
break;
}
return $social_url;
}
/*!
* Displays Author SEO Avatar (Users only)
* @author : Achemli Mouad
* Note : this function is important do not remove from here
*/
function seo_author_avatar($post_id, $author_id) {
$author_image = get_the_author_meta('custom_avatar', $author_id);
if (!empty($author_image)) {
return $author_image;
}
elseif (function_exists('get_wp_user_avatar')) {
return get_wp_user_avatar_src( $author_id, 'thumbnail');
}
elseif (function_exists('get_avatar')) {
return get_avatar_url(get_the_author_meta( 'ID' ));
}
}
/*!
* Displays Avatar SEO => (Custom Categories Articles)
* @author : Achemli Mouad
* Note : this function is important do not remove from here
*/
function seo_author_thumbnail($post_id, $author_id) {
$image = false;
$author_image = get_the_author_meta('custom_avatar', $author_id);
$meta_image = mwp_option('author_photo');
$print_image = get_post_meta($post_id, $meta_image, true);
if (!empty($print_image) ) {
return $print_image;
} elseif (!empty($author_image)) {
return $author_image;
} elseif (function_exists('get_wp_user_avatar')) {
return get_wp_user_avatar_src( $author_id, 'thumbnail');
} elseif (function_exists('get_avatar')) {
return get_avatar_url(get_the_author_meta( 'ID' ));
}
}
/*!
* Displays Author name SEO => (Custom Categories Articles)
* @author : Achemli Mouad
* Note : this function is important do not remove from here
*/
function seo_author_name($post_id, $author_id) {
$meta_name = mwp_option('author_name');
$print_name = get_post_meta($post_id, $meta_name, true);
$author_name = get_the_author_meta('display_name', $author_id);
if (!empty($print_name)) {
$name = $print_name;
} else {
$name = $author_name;
}
return $name;
}
/*
=============================================================
+ +
+ +
+ DESCRIPTION +
+ +
+ +
=============================================================
*/
/*!
* SEO Helper : Description clean list
* list of special characters to remove from meta description
* @author : Mouad Achemli
*/
function seo_description_characters() {
$characters = array(
".",
"," ,
"..",
"...",
")",
"(",
"=",
"”",
"“",
'"',
"'",
"…",
"\r",
"\n",
" ",
"،",
"«",
"»",
"?",
"�"
);
return $characters;
}
/*!
* SEO Helper : Limit words
* @author : Achemli Mouad
*/
function mwp_limit_words($data, $limit) {
$content = explode(' ', $data, $limit);
if (count($content) >= $limit) {
array_pop($content);
$content = implode(" ",$content);
} else {
$content = implode(" ",$content);
}
return $content;
}
/*!
* SEO Helper : Remove breaking words
* find substring without breaking words
* @author : Aneeska
* @source : http://ask.amoeba.co.in/?p=197
*/
function remove_break_words($content) {
wp_set_internal_encoding();
$text = $content;
$limit = 150;
if (extension_loaded('mbstring')) {
if(substr($text, $limit, 1) != ' ' && ($l = mb_strrpos(mb_substr($text, 0, $limit), ' '))) {
return mb_substr($text, 0, $l);
} else {
return mb_substr($text, 0, $limit);
}
} else {
$characters = seo_description_characters();
$content = mwp_limit_words($text, 30);
$content = str_replace($characters, ' ', $content);
$content = str_replace(']]>', ']]>', $content);
$content = str_replace(array("\r", "\n"), '', $content);
return $content;
}
}
/*!
* SEO Helper : Generate Description
* get content and clean for display
* @author : Achemli Mouad
*/
function seo_generate_description($type, $postid) {
switch ($type) {
case 'seo' :
$limit = 80;
$data = get_post_meta($postid, 'mwp_seo_desc' , true);
$content = mwp_limit_words($data, $limit);
$content = str_replace('...', ' ', $content);
break;
case 'page' :
$limit = 80;
$data = get_post_meta($postid, 'seo_page_desc' , true);
$content = mwp_limit_words($data, $limit);
$content = str_replace('...', ' ', $content);
break;
case 'excerpt' :
$limit = 300;
$data = mwp_post_excerpt($postid);
$content = mwp_limit_words($data, $limit);
$content = str_replace('...', ' ', $content);
break;
case 'content' :
$limit = 300;
$data = mwp_post_content($postid);
$content = mwp_limit_words($data, $limit);
$content = str_replace('...', ' ', $content);
break;
case 'title' :
$limit = 1000;
$data = get_the_title($postid);
$content = mwp_limit_words($data, $limit);
$content = str_replace('...', ' ', $content);
break;
}
return $content;
}
/*!
* SEO Helper : Generate Description
* get post content and clean for display
* @author : Achemli Mouad
*/
function mwp_seo_content($postid) {
$seo_desc = seo_generate_description('seo', $postid);
$page_desc = seo_generate_description('page', $postid);
$post_title = seo_generate_description('title', $postid);
$post_excerpt = seo_generate_description('excerpt', $postid);
$post_content = seo_generate_description('content', $postid);
if (!empty($seo_desc)) {
return $seo_desc;
} elseif (!empty($page_desc)) {
return $page_desc;
} elseif (!empty($post_excerpt)) {
return $post_excerpt;
} elseif (!empty($post_content)) {
return $post_content;
} else {
return $post_title;
}
}
/*!
* SEO Helper : Display Description
* display description based on conditional tags
* @author : Achemli Mouad
*/
function mwp_seo_description($postid) {
if(is_page()) {
$content = mwp_seo_content($postid);
}
elseif (is_singular() || is_attachment()) {
$content = mwp_seo_content($postid);
}
elseif ( is_author() ) {
$id = get_queried_object_id();
$content = get_user_meta( $id, 'description', true );
}
elseif ( is_category() && category_description() ) {
$content = category_description();
$content = strip_tags($content);
$content = str_replace(array("\r", "\n"), '', $content);
}
elseif ( is_tag() && tag_description() ) {
$content = tag_description();
$content = strip_tags($content);
$content = str_replace(array("\r", "\n"), '', $content);
}
elseif ( is_archive() && function_exists( 'get_the_archive_description' ) && get_the_archive_description() ) {
$content = get_the_archive_description();
}
else {
$content = '';
}
return $content;
}
/*!
* SEO Helper : Social Description
* display Social description based on conditional tags
* @author : Achemli Mouad
*/
function mwp_social_description($postid) {
$data = get_post_meta($postid, 'mwp_social_desc' , true);
if (!empty($data)) {
$description = $data;
} else {
$post_data = get_post($postid);
$data = $post_data->post_content;
$content = mwp_seo_content($postid);
$description = $content;
}
return $description;
}
/*
=============================================================
+ +
+ +
+ KEYWORDS +
+ +
+ +
=============================================================
*/
/*!
* SEO Helper : Words list exclude from meta keywords
* @author : Mouad Achemli
*/
function keywords_list() {
$exclude_keys = array(
'في',
'من',
'الى',
'إلى',
'عن',
'بعد',
'أي',
'اي',
'على',
'بـ',
'اول',
'ثاني',
'مع',
'حول',
'اثناء',
'أثناء',
'رد',
'رداً',
'عبر',
'أسابيع',
'شهور',
'سنة',
'سنوات',
'ايام',
'أيام',
'يوم',
'يومين',
'الماضية',
'الماضي',
'شهر',
'نصف',
'ربع',
'ادني',
'كامل',
'شراء',
'انا',
'أنا',
'نحن',
'قبل',
'بعد',
'كان',
'كانت',
'هن',
'رجل',
'ولاية',
'لا',
'لن',
'عدة',
'قرب',
'هل',
'فى',
'ما',
'عام',
'لكنها',
'هو',
'هي',
'احد',
'كبار',
'الـ',
'بالصور',
'بالفيديو',
'هذه',
'هذا',
'رغم',
'اخيرا',
'أخيراً',
'آخر',
'غير',
'حيث',
'سلمان',
'كل',
'فقط',
'كذالك',
'لكن',
'لماذا',
'ليس',
'ليت',
'ليث',
'لان',
'لأن',
'لو',
'يقر',
'زلت',
'لأي',
'ماذا',
'قالت',
'قال',
'و',
'مع',
);
return $exclude_keys;
}
/*!
* SEO Helper : Delete Value from Array
* @source : http://stackoverflow.com/a/10455129/2535061
*/
function array_delete($array, $element) {
return array_diff($array, $element);
}
/*!
* SEO Helper : Generate Keywords
* @Developed by : Mouad Achemli
* @author : amercader
* @source : http://stackoverflow.com/a/2302608/2535061
*/
function mwp_seo_page_keywords($postid) {
$seo_keywords = get_post_meta($postid, 'seo_page_keywords' , true);
if (!empty($seo_keywords))
return $seo_keywords;
}
/*!
* SEO Helper : Generate Keywords
* @Developed by : Mouad Achemli
* @author : amercader
* @source : http://stackoverflow.com/a/2302608/2535061
*/
function mwp_seo_keywords($postid) {
$seo_keywords = get_post_meta($postid, 'mwp_seo_keywords' , true);
if (!empty($seo_keywords)) {
$keywords = $seo_keywords;
$characters = seo_description_characters();
$keywords = str_replace($characters, "", $keywords);
} else {
$get_tags = get_the_tags($postid);
$get_title = get_the_title($postid);
$auto_keys = mwp_option('seo-meta-autokeywords');
$keywords = '';
if (!empty($get_tags)) {
$keywords = array();
foreach($get_tags as $keyword) {
$keywords[] = $keyword->name;
}
$characters = seo_description_characters();
$keywords = str_replace($characters, "", $keywords);
$keywords = implode($keywords,", ");
}
elseif ($auto_keys == 1) {
$title_key = explode(' ', $get_title);
$keywords = array();
$characters = seo_description_characters();
foreach($title_key as $keyword) {
if (preg_replace('/[^\w\s]+/u', '', $keyword) && preg_replace('/[0-9]+/', '', $keyword)) {
$keyword = str_replace($characters, "", $keyword);
$keywords[] = $keyword;
}
}
$keywords = array_unique($keywords);
$keywords = array_delete($keywords, keywords_list());
$keywords = implode($keywords,", ");
}
}
return $keywords;
}
/*!
* SEO Helper : Remove special characters
* @Developed by : Mouad Achemli
* @author : Aufziehvogel
* @source : http://stackoverflow.com/a/14542048/2535061
*/
function mwp_seo_keywords_specialchars($string) {
if (preg_replace('/[^\w\s]+/u', '', $string) && preg_replace('/[0-9]+/', '', $string)) {
return true;
} else {
return false;
}
}
/*!
* SEO Helper : Generate Keywords OpenGraph
* @author : Mouad Achemli
*/
function mwp_seo_keywords_opengraph($postid) {
$get_title = get_the_title($postid);
//$get_tags = wp_get_post_tags($postid);
$get_tags = get_the_tags($postid);
$characters = seo_description_characters();
$keywords = '';
if (!empty($get_tags)) {
$keywords = $get_tags;
} else {
$title_keys = explode(' ', $get_title);
$title_keys = str_replace($characters, "", $title_keys);
$keywords = array();
$keywords = array_filter($title_keys, "mwp_seo_keywords_specialchars");
$keywords = array_unique($keywords);
$keywords = array_delete($keywords, keywords_list());
}
return $keywords;
}
/*
=============================================================
+ +
+ +
+ TITLES +
+ +
+ +
=============================================================
*/
/*!
* SEO Helper : Social Title
* get post Title from Custom fields
* @author : Achemli Mouad
*/
function mwp_social_title($postid) {
$data = get_post_meta($postid, 'mwp_social_title' , true);
if (!empty($data)) {
$title = $data;
} else {
$title = get_the_title($postid);
}
return $title;
}
/*!
* SEO Helper : Pages Title
* get page Title from Custom fields
* @author : Achemli Mouad
*/
function mwp_page_title($postid) {
$data = get_post_meta($postid, 'seo_page_title' , true);
if (!empty($data)) {
$title = __($data);
} else {
$title = mwp_seo_title($postid);
}
return $title;
}
/*!
* SEO Helper : Archive Title
* get archive Title from Custom fields
* @author : Achemli Mouad
*/
function mwp_archive_title() {
if ( is_day() ) {
$title = __( 'Archives for ', MWP_TEXT_DOMAIN ) . get_the_time( 'F j, Y' );
} elseif ( is_month() ) {
$title = __( 'Archives for ', MWP_TEXT_DOMAIN ) . single_month_title( ' ', false );
} elseif ( is_year() ) {
$title = __( 'Archives for ', MWP_TEXT_DOMAIN ) . get_the_time( 'Y' );
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} else {
$title = single_term_title("", false);
}
$get_site_name = mwp_option('seo-home-title');
if (!empty($get_site_name)) {
$seo_name = $get_site_name;
} else {
$seo_name = get_bloginfo('name');
}
return $title.' - '.$seo_name;
}
/*!
* SEO Helper : Generate Title
* get post Title and clean for display
* @author : Achemli Mouad
*/
function mwp_seo_title($postid) {
$seo_title = get_post_meta($postid, 'mwp_seo_title' , true);
if (!empty($seo_title)) {
$title = $seo_title;
return $title;
} else {
$title = get_the_title($postid);
$get_site_name = mwp_option('seo-home-title');
if (!empty($get_site_name)) {
$seo_name = $get_site_name;
} else {
$seo_name = get_bloginfo('name');
}
return $title.' - '.$seo_name;
}
}
/*!
* SEO Helper : Category & Tag Title
* get category & tag Title and clean for display
* @author : Achemli Mouad
*/
function mwp_seo_title_tax() {
$limit = 1000;
$content = single_cat_title( '', false );
$get_site_name = mwp_option('seo-home-title');
if (!empty($get_site_name)) {
$seo_name = $get_site_name;
} else {
$seo_name = get_bloginfo('name');
}
return $content.' - '.$seo_name;
}
/*
=============================================================
+ +
+ +
+ VIDEO DURATION +
+ +
+ +
=============================================================
*/
/*!
* Convert duration to ISO 8601 duration standard
* @author : Mouad achemli
* @Note : this function is important do not remove from here
*/
function duration_iso8601_seo($str_time) {
$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
// Check for Long duration
if (sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds) == 3 ) {
$result = ($hours * 60) + $minutes;
$output = 'PT'.$result.'M'.$seconds.'S';
}
// Check for Medium & Low duration
elseif (sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds) == 2 ) {
if (strpos($str_time,'00:') !== false) {
$output = 'PT0M'.$seconds.'S';
} else {
$output = 'PT'.$minutes.'M'.$seconds.'S';
}
}
return $output;
}
/*!
* Get Video Duration
* @author : Mouad Achemli
* @note : this function is important do not remove from here
*/
function check_duration_seo($postid) {
// Get time value from metabox
$time_vid = mwp_option('video_duration');
$time_vid_value = get_post_meta($postid, $time_vid , true);
$key_exists_yt = metadata_exists( 'post', $postid, 'mwp_yt_duration' );
$key_exists_vi = metadata_exists( 'post', $postid, 'mwp_vi_duration' );
$key_exists_dm = metadata_exists( 'post', $postid, 'mwp_dm_duration' );
$key_exists_sp = metadata_exists( 'post', $postid, $time_vid );
// Get New custom field value (Video ID)
$check_y = get_post_meta($postid, 'mwp_yt_duration' , true);
$check_v = get_post_meta($postid, 'mwp_vi_duration' , true);
$check_d = get_post_meta($postid, 'mwp_dm_duration' , true);
if ($key_exists_sp == true && !empty($time_vid_value) ) {
return $time_vid_value;
} elseif ($key_exists_yt == true && !empty($check_y)) {
return $check_y;
} elseif ($key_exists_vi == true && !empty($check_v)) {
return $check_v;
} elseif ($key_exists_dm == true && !empty($check_d)) {
return $check_d;
} else {
return '00:00';
}
}
/*
* check Theme SEO Enabled
*/
if ( mwp_option('seo-enable') == 1) {
/*
=============================================================
+ +
+ +
+ OPRN GRAPH PREFIX +
+ +
+ +
=============================================================
*/
/*!
* Register filters for opengraph prefixes
* source : https://github.com/willnorris/wordpress-opengraph/blob/master/opengraph.php
*/
function opengraph_register() {
add_filter( 'opengraph_prefixes', 'mwp_opengraph_additional' );
}
add_action( 'wp', 'opengraph_register' );
/*!
* Add Open Graph XML prefix to <html> element.
* @uses apply_filters calls 'opengraph_prefixes' filter on RDFa prefix array
*/
function mwp_opengraph_add_prefix( $output ) {
$prefixes = array(
'og' => 'http://ogp.me/ns#',
);
$prefixes = apply_filters( 'opengraph_prefixes', $prefixes );
$prefix_str = '';
foreach ( $prefixes as $k => $v ) {
$prefix_str .= $k . ': ' . $v . ' ';
}
$prefix_str = trim( $prefix_str );
if ( preg_match( '/(prefix\s*=\s*[\"|\'])/i', $output ) ) {
$output = preg_replace( '/(prefix\s*=\s*[\"|\'])/i', '${1}' . $prefix_str, $output );
} else {
$output .= ' prefix="' . $prefix_str . '"';
}
return $output;
}
add_filter( 'language_attributes', 'mwp_opengraph_add_prefix' );
/*!
* Add additional prefix namespaces that are supported by the opengraph plugin.
*/
function mwp_opengraph_additional( $prefixes ) {
$videos_ids = mwp_option('category-videos');
if ( is_author() ) {
$prefixes['profile'] = 'http://ogp.me/ns/profile#';
}
elseif (!empty($videos_ids) && in_category($videos_ids) && is_singular('post')) {
$prefixes['fb'] = 'http://ogp.me/ns/fb#';
$prefixes['video'] = 'http://ogp.me/ns/video#';
unset($prefixes['og']);
}
elseif ( is_singular() ) {
$prefixes['article'] = 'http://ogp.me/ns/article#';
}
return $prefixes;
}
/*
=============================================================
+ +
+ +
+ PERMALINK HELPER +
+ +
+ +
=============================================================
*/
/*!
* Function name : Replace the default rel_canonical
* Function Description : This new function adds gets the paginated page from the URL and adds it to the canonical link.
* : It will also add next and previous links to the adjacent pages so Google knows
* Author Name : shea
* Function Source : https://wordpress.stackexchange.com/a/84711/40961
* Note : this function is important do not remove from here
*
*/
function mwp_rel_canonical() {
/* Only affect singular posts. */
if ( ! is_singular() )
return;
/* Get the post permalink */
$post = get_queried_object();
$link = trailingslashit( get_permalink( $post->ID ) );
/* Get the number of pages the post is split into */
$numpages = substr_count( $post->post_content, '<!--nextpage-->' ) + 1;
/* Get the current pagination page number */
$page = ( get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 );
/* Add the page number if the post is paginated */
if ( $numpages && $page > 1 )
$canonical = user_trailingslashit( $link . $page );
else
$canonical = get_permalink( $post->ID );
/* Output the canonical link */
printf ( "\n" . '<link rel="canonical" href="%s" />', $canonical );
/* Add the adjacent rel links */
if ( $page > 1 ) {
/* Link to the previous adjacent post */
$prev = $page - 1;
if ( $prev > 1 )
printf ( "\n" . '<link rel="prev" href="%s" />', user_trailingslashit( $link . $prev ) );
else
printf ( "\n" . '<link rel="prev" href="%s" />', get_permalink( $post->ID ) );
}
if ( $page < $numpages ) {
/* Link to the next adjacent post */
$next = $page + 1;
printf ( "\n" . '<link rel="next" href="%s" />', user_trailingslashit( $link . $next ) );
}
print "\n";
}
remove_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_head', 'mwp_rel_canonical', 9 );
/*
* Function name : Remove links adjacent_posts_rel_link_wp_head
* Function Description : Helper @mwp_rel_canonical
* Author Name : Mouad Achemli
* Note : this function is important do not remove from here
*
*/
function mwp_remove_adjacent_posts_rel_link_wp_head() {
if( is_singular() )
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head');
}
add_action('wp', 'mwp_remove_adjacent_posts_rel_link_wp_head');
} // end of check seo if enabled
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists