0

Error:

Notice: Undefined index: link_type in /home/golchind/public_html/wp-content/themes/golchindl/functions.php on line 40

Notice: Trying to get property of non-object in /home/golchind/public_html/wp-content/themes/golchindl/functions.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at /home/golchind/public_html/wp-content/themes/golchindl/functions.php:40) in /home/golchind/public_html/wp-admin/admin-header.php on line 9

help :

line 40

$type = $_POST['link_type'];

line 58

update_post_meta($post->ID,"_oscar_data",json_encode(array("episodes"=>$episodes,"links"=>$links,"type"=>$type), JSON_UNESCAPED_UNICODE));

function oscar_meta_box_js(){
    wp_enqueue_style( 'oscar_box_style',get_bloginfo('template_url')."/css/admin_meta_box.css");
    wp_enqueue_script( 'oscar_box', get_bloginfo('template_url'). '/js/meta_boxes.js', array('jquery'),'1.0',true);
}
add_action( 'admin_enqueue_scripts', 'oscar_meta_box_js');


function oscar_meta_save(){
    global $post,$meta_args,$meta_dls;
    $type = $_POST['link_type'];
    $episodes = array();
    $links = array();
    if($type == "serial"){
        for($i=0;$i<count($_POST['ep_name']);$i++){
            $episodes[] = array("name"=>$_POST['ep_name'][$i],"quality"=>$_POST['ep_quality'][$i],"medium_size"=>$_POST['ep_med'][$i]);
        }
        for($i=0;$i<count($_POST['link']);$i++){
            $links[] = array("name"=>$_POST['name'][$i],"link"=>$_POST['link'][$i],"subtitle"=>$_POST['subtitle'][$i],"screenshot"=>$_POST['screenshot'][$i],"episode"=>$_POST['episode'][$i]);
        }
    } else if($type == "movie") {
        for($i=0;$i<count($_POST['movie_title']);$i++){
            $episodes[] = array("name"=>$_POST['movie_title'][$i]);
        }
        for($i=0;$i<count($_POST['mlink']);$i++){
            $links[] = array("name"=>$_POST['mname'][$i],"link"=>$_POST['mlink'][$i],"subtitle"=>$_POST['msubtitle'][$i],"screenshot"=>$_POST['mscreenshot'][$i],"episode"=>$_POST['mtitle'][$i]);
        }
    }
    update_post_meta($post->ID,"_oscar_data",json_encode(array("episodes"=>$episodes,"links"=>$links,"type"=>$type), JSON_UNESCAPED_UNICODE));
}







function oscar_download(){
    global $post;
    ?>
<script>
var $ = jQuery;
$(function(){
    var data = '<?=get_post_meta($post->ID,"_oscar_data",true);?>';
    if(data != ""){
        data = JSON.parse(data);
        var type = data['type'];
        data['episodes'].forEach(function(e){
            if(type == "serial")
                add_ep(e['name'],e['quality'],e['medium_size'])
            else
                add_title(e['name']);
        });
        data['links'].forEach(function(e){
            if(type == "serial")
                add_link(e['name'],e['link'],e['subtitle'],e['screenshot'],e['episode'])
            else
                add_mlink(e['name'],e['link'],e['subtitle'],e['screenshot'],e['episode'])
        });
        if(data['type']){
          $("#link_type").val(data['type']);
    }
    }
    normalize_links()
    normalize_mlinks()
});
</script>
<?php if ('series' == get_post_type()) { ?>
<div id="serial" class="content">
    <div class="side_inp_keeper">
        <input id="title_serial" type="text" placeholder="عنوان فصل">
        <input id="quality_serial" type="text" placeholder="کیفیت">
        <input id="med_serial" type="text" placeholder="میانگین حجم هم قسمت">
        <button id="add_ep" class="button">افزودن</button>
    </div>
    <div id="episodes">

    </div>
    <hr>
    <div class="links" style="display:none;">
            <div class="side_inp_keeper">
                <select id="ep"></select>
                <input type="text" id="name" placeholder="عنوان لینک">
                <input type="text" id="link" placeholder="لینک دانلود">
                <input type="text" id="subtitle" placeholder="زیر نویس">
                <input type="text" id="screenshot" placeholder="نمونه کیفیت">
                <button id="add_link" class="button">افزودن</button>
            </div>
            <div id="links">

            </div>
        </div>
</div>
<?php } else if ('movies' == get_post_type()) { ?>
<div id="movie" class="content">
    <div class="side_inp_keeper">
        <input type="text" name="movie_title" id="movie_title" placeholder="عنوان (مثال : زبان اصلی)"><button id="add_link_title" class="button">افزودن</button>
    </div>
    <div id="titles">

    </div>
    <hr>
    <div class="mlinks">
        <div class="side_inp_keeper">
                    <select id="titl"></select>
                    <input type="text" id="mname" placeholder="عنوان لینک">
                    <input type="text" id="mlink" placeholder="لینک دانلود">
                    <input type="text" id="msubtitle" placeholder="زیر نویس">
                    <input type="text" id="mscreenshot" placeholder="نمونه کیفیت">
                    <button id="add_mlink" class="button">افزودن</button>
        </div>
        <div id="mlinks">

        </div>
    </div>
</div>
<?php } ?>
<input type="hidden" name="link_type" id="link_type" value="serial">
    <?php
}



function oscar_meta_boxes() {
    add_meta_box( 'oscar_download',"باکس دانلود", 'oscar_download', array('movies', 'series'), 'normal', 'high' );
}
add_action("save_post","oscar_meta_save");
add_action( 'add_meta_boxes', 'oscar_meta_boxes' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.