<?php defined('ABSPATH') || die('Cheatin\' uh?'); ?>

<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'> 
<?php
//   $token=NXTLVL_Classes_Helpers_Tools::getOption('token_res');
//   $code=NXTLVL_Classes_Helpers_Tools::getOption('code_res');
//   $acount_id=NXTLVL_Classes_Helpers_Tools::getOption('account_id');
//   echo get_post_meta( 3581,'authorization',true);



//  $argsCheck = array(
//      'method'      => 'POST',  
//      'timeout'     => 50,
//      'redirection' => 5,
//      'httpversion' => '1.0',
//      'blocking'    => true,
//      'headers'     =>array('Content-Type' => 'application/json','x-authorization'=>'ZbHACrqv3vba'),
//      'body' => wp_json_encode(array(
//                  "token"=> $token,
//                  "token_code"=> $code,
//                  "account_id"=> $acount_id,
//              )),
//      'cookies' => array());

//      error_reporting(E_ERROR | E_PARSE);

//      $inputJSONCheck = wp_remote_post("https://app.nextlevelmarketing.ai/api/pub/articles/to_publish",$argsCheck);
//      $apiBodyCheck  = json_decode($inputJSONCheck['body']);
//     // print_r( $apiBodyCheck);
//     update_post_meta(3581,'authorization','apFDsrlK');

//      //**Get each post body    
//      foreach($apiBodyCheck->payload as $payload){
//         echo $payload->aid."--".$payload->authorization."--".$payload->title;
//       //  echo  $payload->authorization;
//             //print_r($payload);
//              $postBody = array(
//                  'method'      => 'POST',  
//                  'timeout'     => 50,
//                  'redirection' => 5,
//                  'httpversion' => '1.0',
//                  'blocking'    => true,
//                  'headers'     => array('Content-Type' => 'application/json','x-authorization'=>'ZbHACrqv3vba'),
//                  'body'        => wp_json_encode(array(
//                  "article_id"  => $payload->aid,
//                  "authorization" => $payload->authorization,
//                  )),
//                  'cookies' => array()
//              );
        
//              error_reporting(E_ERROR | E_PARSE);
//              $body = wp_remote_post("https://app.nextlevelmarketing.ai/api/pub/articles/get",$postBody);    
//              $data_result = json_decode($body['body']);

            // echo "---->".$data_result->payload[0]."--";
      // print_r($data_result->payload[0]);
    //   }




// $token=NXTLVL_Classes_Helpers_Tools::getOption('token_res');
// $code=NXTLVL_Classes_Helpers_Tools::getOption('code_res');
  
// $argsCheck = array(
//     'method'      => 'POST',  
//     'timeout'     => 50,
//     'redirection' => 5,
//     'httpversion' => '1.0',
//     'blocking'    => true,
//     'headers'     =>array('Content-Type' => 'application/json','x-authorization'=>'ZbHACrqv3vba'),
//     'body' => wp_json_encode(array(
//         "token"=> $token,
//         "token_code"=>$code,
//         "account_id"=> "10",     
//     )),
//     'cookies' => array());

//     error_reporting(E_ERROR | E_PARSE);
//     $inputJSONCheck = wp_remote_post("https://app.nextlevelmarketing.ai/api/pub/articles/to_publish",$argsCheck);
//     $apiBodyCheck  = json_decode($inputJSONCheck['body']);
    
//     print_r( $apiBodyCheck );
    //**Get each post body    
            
    // foreach($apiBodyCheck->payload as $payload){
    //        //print_r($payload);
    //         $postBody = array(
    //             'method'      => 'POST',  
    //             'timeout'     => 50,
    //             'redirection' => 5,
    //             'httpversion' => '1.0',
    //             'blocking'    => true,
    //             'headers'     => array('Content-Type' => 'application/json','x-authorization'=>'ZbHACrqv3vba'),
    //             'body'        => wp_json_encode(array(
    //             "article_id"  => $payload->aid,
    //             "authorization" => $payload->authorization,
    //             )),
    //             'cookies' => array()
    //         );
       
    //         error_reporting(E_ERROR | E_PARSE);
    //         $body = wp_remote_post("https://app.nextlevelmarketing.ai/api/pub/articles/get",$postBody);    
    //         $data_result = json_decode($body['body']);

    //         print_r($data_result);
    // }
    //update_post_meta(3584,"desctiption","hello");
?>

<!--Edit author info-->
<div style="width:100%;margin-top:0px; background-color:#EBEBEC;">

    <?php if (!class_exists('SQ_Classes_ObjController') ) {
        echo '<div class="install-sq" style="margin-left:15%;display:flex;flex-direction:column;width:70vw;margin-top:3vw;background-color:black;background-image:radial-gradient(at 59% 100%, hsla(180, 100%, 10%, 1) 0px, transparent 50%), radial-gradient(at 0% 42%, hsla(180, 100%, 11%, 1) 0px, transparent 50%), radial-gradient(at 100% 4%, hsla(180, 100%, 17%, 1) 0px, transparent 50%);top:5vw;box-shadow: 0 4px 30px rgba(0,0,0, 0.3);border-radius:16px;backdrop-filter: blur(12px);padding-left:30px;padding-top:20px;">
                <div style="display:flex;">
                    <img class="squirrel" style="height:80px;width:80px;" src="'.plugins_url(). "/nextlevel/view/assets/img/squirrel.png".'" />
                    
                    <div style="display:flex;flex-direction:column;width:38vw;margin-left:10px;">
                        <div style="font-weight:700;font-size:24px;color:white;">Install and activate Squirrly Seo</div>
                        <div style="font-size:14px;font-weight:500;margin-top:-2px;line-height:1.2vw;color:#53DFFF">Optimize your content for search engines and your audience with personalized optimization suggestions from Squirrly, including keyword usage, meta tags, and content length.</div>
                    </div>
                </div>
            
                <div class="" style="display:flex;margin-bottom:30px;">
                    <div class="makeNewPost install-btn" style="margin-top:10px;width:160px;height:50px;background-color:#50E0FE;color:black;border-radius:30px;font-weight:700;display:flex;align-items:center;justify-content:center;">Install now</div>
                    <div class="checkmark-install" style="color:green;font-weight:600;font-size:24px;margin-left:25px;margin-top:1px;display:none;">&#9989;</div>
                </div>
            </div>';
    }?>

    <div id="display-all-themes all-themes-styles"  style="background-image:radial-gradient(at 59% 100%, hsla(180, 100%, 10%, 1) 0px, transparent 50%), radial-gradient(at 0% 42%, hsla(180, 100%, 11%, 1) 0px, transparent 50%), radial-gradient(at 100% 4%, hsla(180, 100%, 17%, 1) 0px, transparent 50%);margin-top:5vh;margin-left:15%;min-height:50px;width:70vw;background-color:#010101;box-shadow: 0 4px 30px rgba(0,0,0, 0.4);border-radius:16px;backdrop-filter: blur(12px);padding-left:2vw;padding-top:1vw;padding-bottom:2vw;">
        
        <a href="<?php echo esc_url(NXTLVL_Classes_Helpers_Tools::getAdminUrl("next_lvl","PostGroup"));?>" style="none;">
            <div class="manage-post-nav" style="">
                Scheduled posts<i style="position:absolute;margin-top:1px;right:14px;font-weight:900;font-size:1.5vw;" class="bx bx-chevron-right"></i>
            </div>
        </a>

        <div style="height:65px;background-color:#033;color:white;font-weight:600;position:absolute;width:100%;top:-68px;right:0px;bottom:20px;display:none;">
            <div style="width:100%;display:flex;font-size:19px;height:100%;">
                <div style="width:43.6vw;height:100%;"><div style="margin-top:15px;margin-left:20px;">Title:</div></div>
                <div style="width:20vw;"><div style="margin-top:15px;margin-left:20px;">METAs:</div></div> 
                <div style="width:40vw;"><div style="margin-top:15px;margin-left:20px;">Publish as:</div></div>  
            </div>
        </div>

        <div>
            <?php //**Get api content 
                NXTLVL_Controllers_Settings::get_and_save_content_into_posts();
              
                $postslist = NXTLVL_Controllers_Settings::get_posts();
              
                if ($postslist->have_posts()){
                    foreach($postslist->posts as $post){       
                        if($post->post_status=="publish")
                            $color="#4AC34A";
                        else $color="yellow";

                        echo'<div class="all-posts'.$post->ID.'" style="width:68vw;">
                                <div  style="display:flex;width:66vw;margin-top:1vw;border-radius:3vw;padding:0.5vw;background-color:rgb(80, 224, 254,0.15);" class="post-opt">
                                    <div style="min-height:70px;width:38vw;padding-top:5px;">
                                        <div style="height:100%;font-weight:600;margin-left:20px;padding-top:2px;">
                                            <div style="color:#C9C9C9;line-height:1.3vw;" class="perma-title'.$post->ID.'">'.$post->post_title.'</div>
                                            <div style="font-size:14px;font-weight:500;margin-top:4px;line-height:1.2vw;margin-bottom:5px;color:#1085E1;"><a style="color:#50E0FE;" href='.get_permalink($post->ID).'>'.get_permalink($post->ID).'</a></div>
                                        </div>
                                    </div>

                                    <div style="position:relative;left:5vw;width:12vw;padding-left:20px;display:flex;align-items:center;">
                                        <div class="" style="background-color:'.$color.';width:22px;height:22px;border-radius:50%;"></div>
                                    </div>

                                    <div style="width:5vw;margin-left:11vw;display:flex;align-items:center;">
                                        <div class="toggler-knob'.$post->ID.' meta-checkbox"  style="width:3vw;height:3vw;display:flex;align-items:center;flex-direction:column;gap:5px;justify-content:center;">
                                            <div style="background-color:#50E0FE;width:5px;height:5px;border-radius:50%;"></div>
                                            <div style="background-color:#50E0FE;width:5px;height:5px;border-radius:50%;"></div>
                                            <div style="background-color:#50E0FE;width:5px;height:5px;border-radius:50%;"></div>
                                        </div>
                                        <input class="post_id" type="hidden" value='.$post->ID.' />
                                    </div>

                                    <div style="padding-left:20px;width:20vw;display:flex;align-items:center;position:relative;display:none;">
                                        <div class="dropdown-displays" style="width:220px;height:40px;margin-top:5px;border-radius:20px;z-index:2;display:flex;background-color:rgb(78,224,255,0.9)">
                                            <div class="dropdown-btn-text" style="width:140px;margin-top:5px;padding-left:15px;font-weight:600;">'.get_post_meta( $post->ID,'postType',true).'</div>
                                            <i class="bx bx-chevron-up dropdown-arrow" style="color:black;font-size:1.6vw;font-weight:500;margin-left:15px;margin-top:6px;"></i>
                                        </div>

                                        <div class="pannel-displays closed" style="min-height:50px;width:195px;position:absolute;border-radius:10px;top:65px;color:white;background-color:rgb(41,68,111,0.9);margin-bottom:5px;padding-bottom:5px;z-index:200;">';
                                            $types = get_post_types();  
                                            foreach ($types as $type) {
                                                echo '<div  class="publish-option" style="display:flex;">
                                                        <div class="" style="margin-left:10px;font-weight:600;">'.$type.'</div>
                                                    </div>';}             
                                            echo '<input class="post-id" type="hidden" value="'.$post->ID.'" />
                                        </div>
                                        <div class="publish" style="margin-left:20px;margin-top:5px;font-weight:600;border-radius:5px;border:1px solid black;width:110px;height:40px;display:flex;justify-content:center;padding-top:5px;background-color:#033;color:white;display:none;">Publish</div>
                                        <div class="checkmark" style="color:green;font-weight:600;font-size:24px;margin-left:25px;margin-top:10px;display:none;">&#9989;</div>
                                        <div class="nxt-bin" id="'.$post->ID.'" style="color:red;font-size:18px;margin-top:10px;margin-left:40px;width:60px;height:30px;">Bin</div>
                                    </div>
                                
                                </div>
                                <div style="position:relative;z-index:200;width:66vw;" class="editMetaTags"></div>
                            </div>';
                           
           
                    }
                   // echo NXTLVL_Classes_ObjController::getClass('NXTLVL_Classes_DisplayController')->get_meta_data(3447);

                if (isset($_GET['paged']))
                    $paged = $_GET['paged'];
                else $paged=1;

                if ( $postslist->max_num_pages > 1) {
                    echo   "<div style='padding-left:20px;font-weight:600;font-size:20px;height:60px;padding-top:15px;margin-top:1.5vw;'>" 
                                .paginate_links(array(
                                    'total' => $postslist->max_num_pages,
                                    'format' => '?paged=%#%',
                                    'current' => max( 1, $paged ),
                                    'prev_next' => true,
                                    'prev_text' => __( '&laquo; Previous' ),
                                    'next_text' => 'Next' 
                                        )).
                            "</div>";
                }
            };?>
            
        </div>
    
</div>
<div style="height:3vw;"></div>


<style>
    html{
        min-height:800px;
        background-color:#EBEBEC;
    }
    body{
        min-height:800px;
    }
    .page-numbers{
        border:none;
        padding:15px;
        text-decoration:none;
        color:white;
        background-color:#3c434a;
        border-radius:20px;
        font-weight:500;
    }
    .page-numbers:hover{
        color:aqua;
        opacity:90%;
    }
    .page-numbers.current{
        color:aqua;
    }
    .install-btn:hover{
        opacity:80%;
    }

    .post-opt{
        background-color:rgba(0,0,0, 0.8);   
    }

    .post-opt:hover{
       opacity:0.8;
    } 

    .meta-checkbox:hover{
        border-radius:50%;
        background-color:#010101;
        opacity:0.8;
    }
    .squirrel:hover{
        scale:1.1;
    }
    .manage-post-nav{
        width:10vw;
        height:3vw;
        background-color:rgba(80, 224, 254,0.3);
        color:white;
        font-weight:600;
        font-size:1vw;
        border-radius:3vw;
        padding:0.8vw;
        position:relative;
        margin-top:1vw;
    }
    .manage-post-nav:hover{
        background-color:rgba(80, 224, 254,0.9);
        box-shadow: 0 10px 30px rgba(80, 224, 254, 0.2);
    }
</style>
