2016-11-26 2 views
1

JW 플레이어와 관련된 모든 미리보기 비디오 링크를 재생하고 싶습니다. ww 용 jw player & jw player 7을 설치합니다. 하지만 그것은 새로운 게시물에만 영향을 미칠 수 있습니다! 어떻게 기본 WordPress 비디오 플레이어로 바꿀 수 있습니까?기본 플레이어를 JW 플레이어로 변경

+0

Jw 플레이어가 어떤 종류의 shortcode를 게시물에 추가합니까? – Benoti

+0

이 플러그인을 사용했습니다. wordpress.org/plugins/simple-shortcode-for-jw-player-7/... [jw7-video] – Mohammad

답변

1

필요에 따라 적용 할 작은 스크립트 (다시 삭제하려면 delete_option 행의 주석 처리를 제거하십시오)를 function.php에 넣으십시오.

이 스크립트는 모든 게시물을 찾고 새 shortcode 태그로 바꿉니다.

get_shortcode_regex()has_shortcode은 shortcode가 등록 된 shortcode (add_shortcode()를 통해 추가, 끝에 dummy_shortcode() 참조)가되어야합니다. has_shortcode() 함께

add_action('init', 'se_40815010'); 

function se_40815010(){ 

    if(get_option('se_40815010') == true){ 
     return; 
    } 

    $old_tag = 'video'; 
    $new_tag = 'jw7-video'; 

    $args = array(
     'post_type' =>'post', 
     'posts_per_page'=> -1, 
     'post_status' => 'any' 
    ); 

    $posts = new WP_Query($args); 

    foreach($posts->posts as $post){ 
     if(has_shortcode($post->post_content, $old_tag)){ 

      $pattern = get_shortcode_regex(); 

      if ( preg_match_all('/'. $pattern .'/s', $post->post_content, $matches) 
       && array_key_exists(2, $matches) 
       && in_array($old_tag, $matches[2])) { 

        $new_content = str_replace($matches[2][0], $new_tag, $post->post_content); 

        $post_update = array(
         'ID'=> $post->ID, 
         'post_content'=> $new_content 
        ); 

        $update = wp_update_post($post_update, true); 

        if($update && !is_wp_error($update)){ 
         $result .= 'Post ID '.$post->ID.', gallery shortcode modified.</br>'; 
        } 
        else{ 
         $error_string = $update->get_error_message(); 
         $result .= '<div id="message" class="error"><p>' . $error_string .'</p></div>'; 
        } 
      } 
     } 
    } 

    wp_mail(get_option('admin_email'), 'Shortcode replace', $result); 

    update_option('se_40815010', true); 
} 
// delete_option('se_40815010'); 

은 단축 코드는 add_shortcode()으로 인식하도록 등록되어야한다. 가짜 단축 코드를 만들면 찾고있는 이전 태그가 인식됩니다.

if(get_option('se_40815010')!= true){ 
    add_shortcode('fakegallery', 'dummy_shortcode'); 
} 
function dummy_shortcode($content){ 
    return 'hello world'; 
} 

희망 하시겠습니까?

+1

어떤 종류의 "다운되었습니다", 오류 메시지가없고, 시간이 초과 되었습니까? 나는 정확히 왜 그런지 모르지만 때로는 functions.php의 끝에 php 태그를 닫을 필요가 없습니다. – Benoti

+0

그래서 그것을 제거, 그것은 불가능, 당신은 디버그 모드를 활성화해야합니다. – Benoti

+0

사이트 링크를 공유 할 수 있습니까? – Hitesh

관련 문제