<?php /*Template Name: editcourse */
acf_form_head();
get_header();
global $user_ID, $user_identity, $current_user ;
get_currentuserinfo();
$current_user = wp_get_current_user();
$user_id = get_current_user_id( );

$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$curauth = explode('/', $actual_link);
$curauth = array_filter($curauth);
$post_id = $curauth[5];

$post_author_id = get_post_field( 'post_author', $post_id );
//$post = get_post();

if (!is_user_logged_in() || $current_user->ID != $post_author_id ){
    $home = esc_url(home_url(''));
    header("Location: $home");
    exit;
}
?>
<style>
    .attachments-browser .attachments,
    .attachments-browser .uploader-inline {
        position: absolute;
        top: 5px !important;
        right: 0;
        left: 0 !important;
        bottom: 0;
        overflow: auto;
        outline: 0;
        z-index: 999999999999999999;
        background: #fff;
    }

    .media-toolbar-secondary,
    a.acf-expand-details,
    span.screen-reader-text,
    h2.media-frame-actions-heading.screen-reader-text,
    span.setting.has-description,
    p#alt-text-description,
    span.setting,
    h2.media-frame-menu-heading {
        display: none !important;
    }

    .media-sidebar input[type="text"],
    .media-sidebar textarea,
    .media-sidebar span.name {
        display: none;
    }

    .media-sidebar {
        position: absolute;
        bottom: 0;
        width: 98%;
        max-width: 98% !important;
        right: 0;
        padding: 0 16px 24px;
        z-index: 75;
        border-right: 1px solid #ddd;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mce-toolbar-grp,
    .media-modal-content .attachments-browser .search,
    label.screen-reader-text,
    .media-toolbar-secondary {
        /*display: none!important;*/
    }

    .acf-fields > .acf-field {
        padding: 0;
        margin-bottom: 15px;
        border-top: 0;
        border-bottom: #EEEEEE solid 1px;
    }

    .acf-field input[type="text"] {
        padding: 10px;
        background-color: #eee;
    }
    .acf-button{
        background-color: #c1272c;
        color: #fff;
        padding: 8px 35px;
        border-radius: 30px;
        display: table;
        transition: all 0.5s linear;
    }
    .acf-button:hover{
        background-color: #1b1363;
        color: #fff;
    }

</style>
<section class="content">
    <div class="container">
        <h1 class="sec-tit text-center">
            <?php the_title(); ?>
            -
            <?php echo get_the_title( $post_id ); ?>
        </h1>

        <?php acf_form(array(
            'updated_message' => __('تم تعديل الدرس بنجاح.. جاري المراجعة من قبل الادارة', 'a7md'),
            'post_id' => $post_id,
            'post_title' => true,
            'post_content' => true,
            'save_post' => array(
                'post_type' => 'courses',
                'post_status' => 'draft'
            ),
            'html_submit_button' => '<input type="submit" class="main-hover d-block w-100" value=" _e( \'تعديل الدرس\', \'a7md\' )">'
        )); ?>

    </div>
</section>

<?php get_footer(); ?>
