Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php ///////////////////////////////////// if (!defined('THEME_DIR')) : define('THEM..

Decoded Output download

<?php 
///////////////////////////////////// 
if (!defined('THEME_DIR')) : 
  define('THEME_DIR', get_template_directory() . '/'); 
endif; 
if (!defined('THEME_URL')) : 
  define('THEME_URL', get_template_directory_uri() . '/'); 
endif; 
if (!defined('UI_DIR')) : 
  define('UI_DIR', get_template_directory() . '/UI/'); 
endif; 
if (!defined('UI_URL')) : 
  define('UI_URL', get_template_directory_uri() . '/UI/'); 
endif; 
if (!defined('STANDARD_DIR')) : 
  define('STANDARD_DIR', get_template_directory() . '/Standard/'); 
endif; 
if (!defined('STANDARD_URL')) : 
  define('STANDARD_URL', get_template_directory_uri() . '/Standard/'); 
endif; 
if (!defined('AJAX_DIR')) : 
  define('AJAX_DIR', get_template_directory() . '/Ajaxt/'); 
endif; 
if (!defined('AJAX_URL')) : 
  define('AJAX_URL', get_template_directory_uri() . '/Ajaxt/'); 
endif; 
 
require STANDARD_DIR . "Loader.php"; 
function enqueue_teamwork_script() { 
    wp_enqueue_script('teamwork-ajax', get_template_directory_uri() . '/js/teamwork-ajax.js', array('jquery'), null, true); 
 
    //  ajaxurl  JavaScript 
    wp_localize_script('teamwork-ajax', 'ajaxurl', admin_url('admin-ajax.php')); 
} 
 
add_action('wp_enqueue_scripts', 'enqueue_teamwork_script'); 
 
function load_more_teamwork() { 
    $post_id = intval($_POST['post_id']); 
    $offset = intval($_POST['offset']); 
    $per_page = intval($_POST['per_page']); 
 
    $output = ''; 
 
    $taxonomy_types = ['actor', 'director', 'escritor', 'production']; 
    $all_terms = []; 
 
    foreach ($taxonomy_types as $taxonomy) { 
        if ($terms = get_the_terms($post_id, $taxonomy)) { 
            foreach ($terms as $term) { 
                $all_terms[] = $term; 
            } 
        } 
    } 
 
    $all_terms = array_slice($all_terms, $offset, $per_page); 
 
    foreach ($all_terms as $term) { 
        $taxonomy = $term->taxonomy; //    
        $field_id = 'image_' . $taxonomy; 
        $image_url = get_term_meta($term->term_id, $field_id, true); 
 
        $taxonomy_labels = [ 
            'actor'     => '', 
            'director'  => '', 
            'escritor'  => '', 
            'production'=> '' 
        ]; 
        $taxonomy_label = isset($taxonomy_labels[$taxonomy]) ? $taxonomy_labels[$taxonomy] : ''; 
 
        $output .= '<li style="--image:url(' . esc_url($image_url) . ');">'; 
        $output .= '<a href="' . esc_url(get_term_link($term)) . '">'; 
        $output .= '<span class="Photo"></span>'; 
        $output .= '<div class="ActorName">'; 
        $output .= '<span dir="auto">' . esc_html($term->name) . '</span>'; 
        $output .= '<em dir="auto">' . esc_html($taxonomy_label) . '</em>'; 
        $output .= '</div></a></li>'; 
    } 
 
    if (empty($output)) { 
        echo 'no_more'; 
    } else { 
        echo $output; 
    } 
 
    wp_die(); //  AJAX request 
} 
 
add_action('wp_ajax_load_more_teamwork', 'load_more_teamwork'); 
add_action('wp_ajax_nopriv_load_more_teamwork', 'load_more_teamwork'); 
 
 
///////////////////////////////////// 
function MediaUploader($value='') 
{ 
  wp_enqueue_media(); 
  ?> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script> 
  <script type="text/javascript"> 
    jQuery(document).ready(function($) { 
      $(".cmb-row.cmb-type-text.cmb2-id-imdbID.table-layout .cmb-td").append('<button id="getFromIMDB" type="button" class="button green"> </button>'); 
      $(".cmb-row.cmb-type-text.cmb2-id-ElcinemaIDTXT.table-layout .cmb-td").append('<button id="getFromElcinema" type="button" class="button green"> </button>'); 
      $("#getFromElcinema").click(function(){ 
        $.ajax({ 
          url: '<?=str_replace('http://', 'https://', STANDARD_URL) ?>APIs/ElCinema.php', 
          type:'GET', 
          async:true, 
          data:'id='+$("#ElcinemaIDTXT").val()+'&pid='+$('#post_ID').val(), 
          success: function(msg) { 
            $('body').append(msg); 
          }, 
          error: function(){ 
          } 
        }); 
      }); 
      $('#getFromIMDB').click(function(){ 
        $.ajax({ 
          url: '<?=str_replace('http://', 'https://', STANDARD_URL) ?>APIs/IMDB.php', 
          type:'GET', 
          async:true, 
          data:'id='+$("#imdbID").val()+'&pid='+$('#post_ID').val(), 
          success: function(msg) { 
            $('body').append(msg); 
          }, 
          error: function(){ 
          } 
        }); 
      }); 
    }); 
  </script> 
  <style type="text/css"> 
    @import url(https://fonts.googleapis.com/css?family=Changa:400,700,800); 
    .cmb-row.cmb-type-text.cmb2-id-ElcinemaIDTXT.table-layout input#ElcinemaIDTXT,.cmb-row.cmb-type-text.cmb2-id-imdbID.table-layout input#imdbID{width:calc(100% - 190px)}button.button.green{margin:0!important;width:180px!important;height:40px!important;font-family:Changa!important;padding:0 10px!important;margin-right:10px!important;font-weight:700!important;color:#3c3c3c!important;background:#e8e8e8!important;border:0!important}a.toplevel_page_ThemeXPanel.menu-top-first.menu-top-last{background:#ec1f1f!important;font-family:Changa;font-weight:700!important}#toplevel_page_ThemeXPanel.wp-menu-open>ul>li>a{border-bottom:1px solid #40464c;font-family:Changa;padding:9px 12px!important;color:#b8bdc3!important}#toplevel_page_ThemeXPanel.wp-menu-open>ul>li:last-child a{border:0!important}#toplevel_page_ThemeXPanel.wp-menu-open>ul>li>a.current,#toplevel_page_ThemeXPanel.wp-menu-open>ul>li>a:hover{color:#fff!important}.postbox.cmb2-postbox{font-family:Changa;position:relative}.postbox.cmb2-postbox h2.hndle.ui-sortable-handle{font-family:Changa;background:linear-gradient(to left,rgb(27 177 0 / 34%),rgba(26,119,244,0));padding:14px!important;font-family:Changa;color:#2e4f7b;border-color:rgba(0,0,0,.1)!important}.postbox.cmb2-postbox button.handlediv{top:8px;position:relative;left:7px}.postbox.cmb2-postbox .cmb-th{display:block;float:right;width:20%;height:40px;font-family:Changa;text-align:right;line-height:40px;font-size:15px;font-weight:700;color:#545658;margin-left:0!important;padding-left:0!important}.postbox.cmb2-postbox .inside *{position:relative}.postbox.cmb2-postbox .inside{padding:0 20px}.postbox.cmb2-postbox .cmb2-metabox.cmb-field-list>div{padding:0 0;margin:10px 0;border:0}.postbox.cmb2-postbox .inside .cmb-td input:not([type=checkbox]),.postbox.cmb2-postbox .inside .cmb-td select,.postbox.cmb2-postbox .inside .cmb-td textarea{margin:0;width:100%;height:40px;font-family:Changa;padding:0 10px;border:1px solid #ddd}.postbox.cmb2-postbox .inside .cmb-td textarea{height:150px;max-height:200px}.cmb-th label{padding:0}.postbox.cmb2-postbox .inside .cmb-td .cmb2-upload-file{width:calc(100% - 170px)!important}.postbox.cmb2-postbox .inside .cmb-td .cmb2-upload-button{float:left!important;width:160px!important;font-weight:700;color:#525252!important}.postbox.cmb2-postbox .inside .cmb-td p.cmb2-metabox-description{display:block;width:100%;font-size:12px;font-style:normal;font-weight:700} 
    h3.cmb-group-title.cmbhandle-title { 
      font-family: Changa !important; 
      background: #f1f1f1; 
    } 
    button.cmb-remove-group-row.cmb-remove-group-row-button.alignright.button-secondary { 
      font-family: Changa; 
      font-weight: bold; 
      border: 0; 
      background: #f1f1f1; 
      color: #222; 
      border: 1px solid #DDD; 
      padding: 5px 30px; 
    } 
    .cmb-row.cmb-remove-field-row { 
      padding: 0; 
    } 
  </style> 
  <? 
} 
add_action('admin_enqueue_scripts','MediaUploader'); 
flush_rewrite_rules( true ); 
function RatingsStar($id) { ?> 
  <? if( !wp_is_mobile() ) { ?> 
    <div class="Back"> 
      <span><i class="far fa-star"></i></span> 
      <span><i class="far fa-star"></i></span> 
      <span><i class="far fa-star"></i></span> 
      <span><i class="far fa-star"></i></span> 
      <span><i class="far fa-star"></i></span> 
    </div> 
    <div class="Front"> 
      <? $RateAVG = intval(get_post_meta($id, 'imdbRating', true)); ?> 
      <? if( $RateAVG == 0 ) { ?> 
      <? }else if( $RateAVG >= 1 and $RateAVG <= 2 ) { ?> 
        <? for ($i=0; $i < 1; $i++) { ?> 
          <span><i class="far fa-star"></i></span> 
        <? } ?> 
      <? }else if( $RateAVG >= 2 and $RateAVG <= 4 ) { ?> 
        <? for ($i=0; $i < 2; $i++) { ?> 
          <span><i class="far fa-star"></i></span> 
        <? } ?> 
      <? }else if( $RateAVG >= 4 and $RateAVG <= 6 ) { ?> 
        <? for ($i=0; $i < 3; $i++) { ?> 
          <span><i class="far fa-star"></i></span> 
        <? } ?> 
      <? }else if( $RateAVG >= 6 and $RateAVG <= 8 ) { ?> 
        <? for ($i=0; $i < 4; $i++) { ?> 
          <span><i class="far fa-star"></i></span> 
        <? } ?> 
      <? }else if( $RateAVG >= 8 and $RateAVG <= 9 ) { ?> 
        <? for ($i=0; $i < 4; $i++) { ?> 
          <span><i class="far fa-star"></i></span> 
        <? } ?> 
      <? }else if( $RateAVG > 9 ) { ?> 
        <? for ($i=0; $i < 5; $i++) { ?> 
          <span><i class="far fa-star"></i></span> 
        <? } ?> 
      <? } ?> 
    </div> 
  <? } ?> 
<? } 
 
add_filter( 'query_vars', 'add_query_vars'); 
function add_query_vars($vars){ 
  $vars[] = "watch"; 
  $vars[] = "download"; 
  return $vars; 
} 
 
add_action('init', 'add_endpoints'); 
function add_endpoints() 
{ 
  add_rewrite_endpoint('watch', EP_PERMALINK); 
  add_rewrite_endpoint('download', EP_PERMALINK); 
} 
 
add_filter( 'request', 'filter_request' ); 
function filter_request( $vars ) 
{ 
  if( isset( $vars['watch'] ) ) $vars['watch'] = true; 
  if( isset( $vars['download'] ) ) $vars['download'] = true; 
  return $vars; 
} 
function add_hoverable_class_to_menu_links($atts, $item, $args) { 
    if (isset($atts['class'])) { 
        $atts['class'] .= 'activable hoverable'; 
    } else { 
        $atts['class'] = 'activable hoverable'; 
    } 
    return $atts; 
} 
add_filter('nav_menu_link_attributes', 'add_hoverable_class_to_menu_links', 10, 3); 
/*****************/ 
//  REST API      
add_action('rest_api_init', function() { 
    register_rest_route('edd/v1', '/validate_license/', array( 
        'methods' => 'POST', 
        'callback' => 'edd_validate_license', 
    )); 
    register_rest_route('edd/v1', '/deactivate_license/', array( 
        'methods' => 'POST', 
        'callback' => 'edd_deactivate_license', 
    )); 
}); 
 
function edd_validate_license(WP_REST_Request $request) { 
    $license_key = sanitize_text_field($request->get_param('license_key')); 
    $item_id = sanitize_text_field($request->get_param('item_id')); 
    $product_name = sanitize_text_field($request->get_param('product_name')); 
 
    $api_params = array( 
        'edd_action' => 'activate_license', 
        'license' => $license_key, 
        'item_id' => $item_id, 
        'url' => home_url(), 
    ); 
 
    $response = wp_remote_post('https://themesx.com', array('body' => $api_params)); 
 
    if (is_wp_error($response)) { 
        return new WP_REST_Response(array('error' => true, 'message' => 'API request failed.'), 500); 
    } 
 
    $license_data = json_decode(wp_remote_retrieve_body($response)); 
 
    if ($license_data->success && strtolower($license_data->item_name) === strtolower($product_name)) { 
        update_option('themex_license_status', 'active'); //    
        update_option('themex_license_max', $license_data->license_limit); //     
        return new WP_REST_Response(array( 
            'success' => true, 
            'message' => 'License is valid and product name matches.', 
            'remaining' => $license_data->site_count, //     
            'max' => $license_data->license_limit //     
        ), 200); 
    } else { 
        update_option('themex_license_status', 'inactive'); //    
        return new WP_REST_Response(array('error' => true, 'message' => 'License is invalid or product name does not match.'), 400); 
    } 
} 
 
 
 
function edd_deactivate_license(WP_REST_Request $request) { 
    $license_key = sanitize_text_field($request->get_param('license_key')); 
    $item_id = sanitize_text_field($request->get_param('item_id')); 
 
    $api_params = array( 
        'edd_action' => 'deactivate_license', 
        'license' => $license_key, 
        'item_id' => $item_id, 
        'url' => home_url(), 
    ); 
 
    $response = wp_remote_post('https://themesx.com', array('body' => $api_params)); 
 
    if (is_wp_error($response)) { 
        return new WP_REST_Response(array('error' => true, 'message' => 'API request failed.'), 500); 
    } 
 
    $license_data = json_decode(wp_remote_retrieve_body($response)); 
 
    if ($license_data->success) { 
        delete_option('themex_license_key'); //       
        update_option('themex_license_status', 'inactive'); //    
        return new WP_REST_Response(array('success' => true, 'message' => 'License deactivated successfully.'), 200); 
    } else { 
        return new WP_REST_Response(array('error' => true, 'message' => 'Failed to deactivate the license.'), 400); 
    } 
} 
 
function themex_check_license() { 
    $license_key = get_option('themex_license_key'); 
    $item_id = 914199; //    EDD 
    $product_name = 'WeCima       '; //   
 
    $response = wp_remote_post(get_rest_url(null, 'edd/v1/validate_license/'), array( 
        'body' => array( 
            'license_key' => $license_key, 
            'item_id' => $item_id, 
            'product_name' => $product_name, 
        ), 
    )); 
 
    if (is_wp_error($response)) { 
        return array('status' => false, 'message' => '    API.'); 
    } 
 
    $license_data = json_decode(wp_remote_retrieve_body($response)); 
 
    if ($license_data->success) { 
        //       
        return array( 
            'status' => true, 
            'remaining' => $license_data->remaining, 
            'max' => get_option('themex_license_max') //     
        ); 
    } else { 
        update_option('themex_license_status', 'inactive'); //    
        return array('status' => false, 'message' => '       .'); 
    } 
} 
 
 
function themex_license_page() { 
    $license_info = themex_check_license(); 
    ?> 
<div class="wrap"> 
    <h2>  </h2> 
 
    <?php if ($license_info['status']) : ?> 
        <div class="notice notice-success"> 
            <p><?php echo '  .  ' . esc_html($license_info['remaining']) . ' / ' . esc_html($license_info['max']) . '  .'; ?></p> 
        </div> 
    <?php else : ?> 
        <div class="notice notice-error"> 
            <p><?php echo esc_html($license_info['message']); ?></p> 
        </div> 
    <?php endif; ?> 
 
    <table class="widefat fixed"> 
        <tbody> 
            <tr valign="top"> 
                <th scope="row"> </th> 
                <td> 
                    <form method="post" action="options.php"> 
                        <?php settings_fields('themex_license'); ?> 
                        <?php do_settings_sections('themex_license'); ?> 
                        <input type="text" name="themex_license_key" class="regular-text" value="<?php echo esc_attr(get_option('themex_license_key')); ?>"> 
                </td> 
                <td></td> 
                <td> 
                    <input type="submit" name="submit" id="submit" class="button button-primary" value=" "> 
                    </form> 
                </td> 
            </tr> 
            <?php if ($license_info['status']) : ?> 
                <tr valign="top"> 
                    <td> </td> 
                    <td></td> 
                    <td></td> 
                    <td> 
                        <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> 
                            <input type="hidden" name="action" value="themex_deactivate_license"> 
                            <input type="hidden" name="license_key" value="<?php echo esc_attr(get_option('themex_license_key')); ?>"> 
                            <input type="submit" class="button-secondary" name="themex_license_deactivate" value=" "> 
                        </form> 
                    </td> 
                </tr> 
            <?php endif; ?> 
        </tbody> 
    </table> 
</div> 
    <?php 
} 
 
//         " " 
add_action('admin_post_themex_deactivate_license', 'themex_handle_deactivate_license'); 
function themex_handle_deactivate_license() { 
    $license_key = sanitize_text_field($_POST['license_key']); 
    $item_id = 2092; //    EDD 
 
    $response = wp_remote_post(get_rest_url(null, 'edd/v1/deactivate_license/'), array( 
        'body' => array( 
            'license_key' => $license_key, 
            'item_id' => $item_id, 
        ), 
    )); 
 
    if (!is_wp_error($response)) { 
        $license_data = json_decode(wp_remote_retrieve_body($response)); 
        if ($license_data->success) { 
            delete_option('themex_license_key'); //       
            update_option('themex_license_status', 'inactive'); //    
            wp_redirect(add_query_arg(array('message' => 'license_deactivated'), admin_url('admin.php?page=themex-license'))); 
            exit; 
        } 
    } 
 
    wp_redirect(add_query_arg(array('message' => 'license_deactivate_failed'), admin_url('admin.php?page=themex-license'))); 
    exit; 
} 
 
//    
function themex_license_menu() { 
    add_menu_page('Theme License', ' ', 'manage_options', 'themex-license', 'themex_license_page'); 
} 
add_action('admin_menu', 'themex_license_menu'); 
 
function themex_register_settings() { 
    register_setting('themex_license', 'themex_license_key'); 
} 
add_action('admin_init', 'themex_register_settings'); 
 ?>

Did this file decode correctly?

Original Code

<?php
/////////////////////////////////////
if (!defined('THEME_DIR')) :
  define('THEME_DIR', get_template_directory() . '/');
endif;
if (!defined('THEME_URL')) :
  define('THEME_URL', get_template_directory_uri() . '/');
endif;
if (!defined('UI_DIR')) :
  define('UI_DIR', get_template_directory() . '/UI/');
endif;
if (!defined('UI_URL')) :
  define('UI_URL', get_template_directory_uri() . '/UI/');
endif;
if (!defined('STANDARD_DIR')) :
  define('STANDARD_DIR', get_template_directory() . '/Standard/');
endif;
if (!defined('STANDARD_URL')) :
  define('STANDARD_URL', get_template_directory_uri() . '/Standard/');
endif;
if (!defined('AJAX_DIR')) :
  define('AJAX_DIR', get_template_directory() . '/Ajaxt/');
endif;
if (!defined('AJAX_URL')) :
  define('AJAX_URL', get_template_directory_uri() . '/Ajaxt/');
endif;

require STANDARD_DIR . "Loader.php";
function enqueue_teamwork_script() {
    wp_enqueue_script('teamwork-ajax', get_template_directory_uri() . '/js/teamwork-ajax.js', array('jquery'), null, true);

    //  ajaxurl  JavaScript
    wp_localize_script('teamwork-ajax', 'ajaxurl', admin_url('admin-ajax.php'));
}

add_action('wp_enqueue_scripts', 'enqueue_teamwork_script');

function load_more_teamwork() {
    $post_id = intval($_POST['post_id']);
    $offset = intval($_POST['offset']);
    $per_page = intval($_POST['per_page']);

    $output = '';

    $taxonomy_types = ['actor', 'director', 'escritor', 'production'];
    $all_terms = [];

    foreach ($taxonomy_types as $taxonomy) {
        if ($terms = get_the_terms($post_id, $taxonomy)) {
            foreach ($terms as $term) {
                $all_terms[] = $term;
            }
        }
    }

    $all_terms = array_slice($all_terms, $offset, $per_page);

    foreach ($all_terms as $term) {
        $taxonomy = $term->taxonomy; //   
        $field_id = 'image_' . $taxonomy;
        $image_url = get_term_meta($term->term_id, $field_id, true);

        $taxonomy_labels = [
            'actor'     => '',
            'director'  => '',
            'escritor'  => '',
            'production'=> ''
        ];
        $taxonomy_label = isset($taxonomy_labels[$taxonomy]) ? $taxonomy_labels[$taxonomy] : '';

        $output .= '<li style="--image:url(' . esc_url($image_url) . ');">';
        $output .= '<a href="' . esc_url(get_term_link($term)) . '">';
        $output .= '<span class="Photo"></span>';
        $output .= '<div class="ActorName">';
        $output .= '<span dir="auto">' . esc_html($term->name) . '</span>';
        $output .= '<em dir="auto">' . esc_html($taxonomy_label) . '</em>';
        $output .= '</div></a></li>';
    }

    if (empty($output)) {
        echo 'no_more';
    } else {
        echo $output;
    }

    wp_die(); //  AJAX request
}

add_action('wp_ajax_load_more_teamwork', 'load_more_teamwork');
add_action('wp_ajax_nopriv_load_more_teamwork', 'load_more_teamwork');


/////////////////////////////////////
function MediaUploader($value='')
{
  wp_enqueue_media();
  ?>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
  <script type="text/javascript">
    jQuery(document).ready(function($) {
      $(".cmb-row.cmb-type-text.cmb2-id-imdbID.table-layout .cmb-td").append('<button id="getFromIMDB" type="button" class="button green"> </button>');
      $(".cmb-row.cmb-type-text.cmb2-id-ElcinemaIDTXT.table-layout .cmb-td").append('<button id="getFromElcinema" type="button" class="button green"> </button>');
      $("#getFromElcinema").click(function(){
        $.ajax({
          url: '<?=str_replace('http://', 'https://', STANDARD_URL) ?>APIs/ElCinema.php',
          type:'GET',
          async:true,
          data:'id='+$("#ElcinemaIDTXT").val()+'&pid='+$('#post_ID').val(),
          success: function(msg) {
            $('body').append(msg);
          },
          error: function(){
          }
        });
      });
      $('#getFromIMDB').click(function(){
        $.ajax({
          url: '<?=str_replace('http://', 'https://', STANDARD_URL) ?>APIs/IMDB.php',
          type:'GET',
          async:true,
          data:'id='+$("#imdbID").val()+'&pid='+$('#post_ID').val(),
          success: function(msg) {
            $('body').append(msg);
          },
          error: function(){
          }
        });
      });
    });
  </script>
  <style type="text/css">
    @import url(https://fonts.googleapis.com/css?family=Changa:400,700,800);
    .cmb-row.cmb-type-text.cmb2-id-ElcinemaIDTXT.table-layout input#ElcinemaIDTXT,.cmb-row.cmb-type-text.cmb2-id-imdbID.table-layout input#imdbID{width:calc(100% - 190px)}button.button.green{margin:0!important;width:180px!important;height:40px!important;font-family:Changa!important;padding:0 10px!important;margin-right:10px!important;font-weight:700!important;color:#3c3c3c!important;background:#e8e8e8!important;border:0!important}a.toplevel_page_ThemeXPanel.menu-top-first.menu-top-last{background:#ec1f1f!important;font-family:Changa;font-weight:700!important}#toplevel_page_ThemeXPanel.wp-menu-open>ul>li>a{border-bottom:1px solid #40464c;font-family:Changa;padding:9px 12px!important;color:#b8bdc3!important}#toplevel_page_ThemeXPanel.wp-menu-open>ul>li:last-child a{border:0!important}#toplevel_page_ThemeXPanel.wp-menu-open>ul>li>a.current,#toplevel_page_ThemeXPanel.wp-menu-open>ul>li>a:hover{color:#fff!important}.postbox.cmb2-postbox{font-family:Changa;position:relative}.postbox.cmb2-postbox h2.hndle.ui-sortable-handle{font-family:Changa;background:linear-gradient(to left,rgb(27 177 0 / 34%),rgba(26,119,244,0));padding:14px!important;font-family:Changa;color:#2e4f7b;border-color:rgba(0,0,0,.1)!important}.postbox.cmb2-postbox button.handlediv{top:8px;position:relative;left:7px}.postbox.cmb2-postbox .cmb-th{display:block;float:right;width:20%;height:40px;font-family:Changa;text-align:right;line-height:40px;font-size:15px;font-weight:700;color:#545658;margin-left:0!important;padding-left:0!important}.postbox.cmb2-postbox .inside *{position:relative}.postbox.cmb2-postbox .inside{padding:0 20px}.postbox.cmb2-postbox .cmb2-metabox.cmb-field-list>div{padding:0 0;margin:10px 0;border:0}.postbox.cmb2-postbox .inside .cmb-td input:not([type=checkbox]),.postbox.cmb2-postbox .inside .cmb-td select,.postbox.cmb2-postbox .inside .cmb-td textarea{margin:0;width:100%;height:40px;font-family:Changa;padding:0 10px;border:1px solid #ddd}.postbox.cmb2-postbox .inside .cmb-td textarea{height:150px;max-height:200px}.cmb-th label{padding:0}.postbox.cmb2-postbox .inside .cmb-td .cmb2-upload-file{width:calc(100% - 170px)!important}.postbox.cmb2-postbox .inside .cmb-td .cmb2-upload-button{float:left!important;width:160px!important;font-weight:700;color:#525252!important}.postbox.cmb2-postbox .inside .cmb-td p.cmb2-metabox-description{display:block;width:100%;font-size:12px;font-style:normal;font-weight:700}
    h3.cmb-group-title.cmbhandle-title {
      font-family: Changa !important;
      background: #f1f1f1;
    }
    button.cmb-remove-group-row.cmb-remove-group-row-button.alignright.button-secondary {
      font-family: Changa;
      font-weight: bold;
      border: 0;
      background: #f1f1f1;
      color: #222;
      border: 1px solid #DDD;
      padding: 5px 30px;
    }
    .cmb-row.cmb-remove-field-row {
      padding: 0;
    }
  </style>
  <?
}
add_action('admin_enqueue_scripts','MediaUploader');
flush_rewrite_rules( true );
function RatingsStar($id) { ?>
  <? if( !wp_is_mobile() ) { ?>
    <div class="Back">
      <span><i class="far fa-star"></i></span>
      <span><i class="far fa-star"></i></span>
      <span><i class="far fa-star"></i></span>
      <span><i class="far fa-star"></i></span>
      <span><i class="far fa-star"></i></span>
    </div>
    <div class="Front">
      <? $RateAVG = intval(get_post_meta($id, 'imdbRating', true)); ?>
      <? if( $RateAVG == 0 ) { ?>
      <? }else if( $RateAVG >= 1 and $RateAVG <= 2 ) { ?>
        <? for ($i=0; $i < 1; $i++) { ?>
          <span><i class="far fa-star"></i></span>
        <? } ?>
      <? }else if( $RateAVG >= 2 and $RateAVG <= 4 ) { ?>
        <? for ($i=0; $i < 2; $i++) { ?>
          <span><i class="far fa-star"></i></span>
        <? } ?>
      <? }else if( $RateAVG >= 4 and $RateAVG <= 6 ) { ?>
        <? for ($i=0; $i < 3; $i++) { ?>
          <span><i class="far fa-star"></i></span>
        <? } ?>
      <? }else if( $RateAVG >= 6 and $RateAVG <= 8 ) { ?>
        <? for ($i=0; $i < 4; $i++) { ?>
          <span><i class="far fa-star"></i></span>
        <? } ?>
      <? }else if( $RateAVG >= 8 and $RateAVG <= 9 ) { ?>
        <? for ($i=0; $i < 4; $i++) { ?>
          <span><i class="far fa-star"></i></span>
        <? } ?>
      <? }else if( $RateAVG > 9 ) { ?>
        <? for ($i=0; $i < 5; $i++) { ?>
          <span><i class="far fa-star"></i></span>
        <? } ?>
      <? } ?>
    </div>
  <? } ?>
<? }

add_filter( 'query_vars', 'add_query_vars');
function add_query_vars($vars){
  $vars[] = "watch";
  $vars[] = "download";
  return $vars;
}

add_action('init', 'add_endpoints');
function add_endpoints()
{
  add_rewrite_endpoint('watch', EP_PERMALINK);
  add_rewrite_endpoint('download', EP_PERMALINK);
}

add_filter( 'request', 'filter_request' );
function filter_request( $vars )
{
  if( isset( $vars['watch'] ) ) $vars['watch'] = true;
  if( isset( $vars['download'] ) ) $vars['download'] = true;
  return $vars;
}
function add_hoverable_class_to_menu_links($atts, $item, $args) {
    if (isset($atts['class'])) {
        $atts['class'] .= 'activable hoverable';
    } else {
        $atts['class'] = 'activable hoverable';
    }
    return $atts;
}
add_filter('nav_menu_link_attributes', 'add_hoverable_class_to_menu_links', 10, 3);
/*****************/
//  REST API     
add_action('rest_api_init', function() {
    register_rest_route('edd/v1', '/validate_license/', array(
        'methods' => 'POST',
        'callback' => 'edd_validate_license',
    ));
    register_rest_route('edd/v1', '/deactivate_license/', array(
        'methods' => 'POST',
        'callback' => 'edd_deactivate_license',
    ));
});

function edd_validate_license(WP_REST_Request $request) {
    $license_key = sanitize_text_field($request->get_param('license_key'));
    $item_id = sanitize_text_field($request->get_param('item_id'));
    $product_name = sanitize_text_field($request->get_param('product_name'));

    $api_params = array(
        'edd_action' => 'activate_license',
        'license' => $license_key,
        'item_id' => $item_id,
        'url' => home_url(),
    );

    $response = wp_remote_post('https://themesx.com', array('body' => $api_params));

    if (is_wp_error($response)) {
        return new WP_REST_Response(array('error' => true, 'message' => 'API request failed.'), 500);
    }

    $license_data = json_decode(wp_remote_retrieve_body($response));

    if ($license_data->success && strtolower($license_data->item_name) === strtolower($product_name)) {
        update_option('themex_license_status', 'active'); //   
        update_option('themex_license_max', $license_data->license_limit); //    
        return new WP_REST_Response(array(
            'success' => true,
            'message' => 'License is valid and product name matches.',
            'remaining' => $license_data->site_count, //    
            'max' => $license_data->license_limit //    
        ), 200);
    } else {
        update_option('themex_license_status', 'inactive'); //   
        return new WP_REST_Response(array('error' => true, 'message' => 'License is invalid or product name does not match.'), 400);
    }
}



function edd_deactivate_license(WP_REST_Request $request) {
    $license_key = sanitize_text_field($request->get_param('license_key'));
    $item_id = sanitize_text_field($request->get_param('item_id'));

    $api_params = array(
        'edd_action' => 'deactivate_license',
        'license' => $license_key,
        'item_id' => $item_id,
        'url' => home_url(),
    );

    $response = wp_remote_post('https://themesx.com', array('body' => $api_params));

    if (is_wp_error($response)) {
        return new WP_REST_Response(array('error' => true, 'message' => 'API request failed.'), 500);
    }

    $license_data = json_decode(wp_remote_retrieve_body($response));

    if ($license_data->success) {
        delete_option('themex_license_key'); //      
        update_option('themex_license_status', 'inactive'); //   
        return new WP_REST_Response(array('success' => true, 'message' => 'License deactivated successfully.'), 200);
    } else {
        return new WP_REST_Response(array('error' => true, 'message' => 'Failed to deactivate the license.'), 400);
    }
}

function themex_check_license() {
    $license_key = get_option('themex_license_key');
    $item_id = 914199; //    EDD
    $product_name = 'WeCima       '; //  

    $response = wp_remote_post(get_rest_url(null, 'edd/v1/validate_license/'), array(
        'body' => array(
            'license_key' => $license_key,
            'item_id' => $item_id,
            'product_name' => $product_name,
        ),
    ));

    if (is_wp_error($response)) {
        return array('status' => false, 'message' => '    API.');
    }

    $license_data = json_decode(wp_remote_retrieve_body($response));

    if ($license_data->success) {
        //      
        return array(
            'status' => true,
            'remaining' => $license_data->remaining,
            'max' => get_option('themex_license_max') //    
        );
    } else {
        update_option('themex_license_status', 'inactive'); //   
        return array('status' => false, 'message' => '       .');
    }
}


function themex_license_page() {
    $license_info = themex_check_license();
    ?>
<div class="wrap">
    <h2>  </h2>

    <?php if ($license_info['status']) : ?>
        <div class="notice notice-success">
            <p><?php echo '  .  ' . esc_html($license_info['remaining']) . ' / ' . esc_html($license_info['max']) . '  .'; ?></p>
        </div>
    <?php else : ?>
        <div class="notice notice-error">
            <p><?php echo esc_html($license_info['message']); ?></p>
        </div>
    <?php endif; ?>

    <table class="widefat fixed">
        <tbody>
            <tr valign="top">
                <th scope="row"> </th>
                <td>
                    <form method="post" action="options.php">
                        <?php settings_fields('themex_license'); ?>
                        <?php do_settings_sections('themex_license'); ?>
                        <input type="text" name="themex_license_key" class="regular-text" value="<?php echo esc_attr(get_option('themex_license_key')); ?>">
                </td>
                <td></td>
                <td>
                    <input type="submit" name="submit" id="submit" class="button button-primary" value=" ">
                    </form>
                </td>
            </tr>
            <?php if ($license_info['status']) : ?>
                <tr valign="top">
                    <td> </td>
                    <td></td>
                    <td></td>
                    <td>
                        <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                            <input type="hidden" name="action" value="themex_deactivate_license">
                            <input type="hidden" name="license_key" value="<?php echo esc_attr(get_option('themex_license_key')); ?>">
                            <input type="submit" class="button-secondary" name="themex_license_deactivate" value=" ">
                        </form>
                    </td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
    <?php
}

//         " "
add_action('admin_post_themex_deactivate_license', 'themex_handle_deactivate_license');
function themex_handle_deactivate_license() {
    $license_key = sanitize_text_field($_POST['license_key']);
    $item_id = 2092; //    EDD

    $response = wp_remote_post(get_rest_url(null, 'edd/v1/deactivate_license/'), array(
        'body' => array(
            'license_key' => $license_key,
            'item_id' => $item_id,
        ),
    ));

    if (!is_wp_error($response)) {
        $license_data = json_decode(wp_remote_retrieve_body($response));
        if ($license_data->success) {
            delete_option('themex_license_key'); //      
            update_option('themex_license_status', 'inactive'); //   
            wp_redirect(add_query_arg(array('message' => 'license_deactivated'), admin_url('admin.php?page=themex-license')));
            exit;
        }
    }

    wp_redirect(add_query_arg(array('message' => 'license_deactivate_failed'), admin_url('admin.php?page=themex-license')));
    exit;
}

//   
function themex_license_menu() {
    add_menu_page('Theme License', ' ', 'manage_options', 'themex-license', 'themex_license_page');
}
add_action('admin_menu', 'themex_license_menu');

function themex_register_settings() {
    register_setting('themex_license', 'themex_license_key');
}
add_action('admin_init', 'themex_register_settings');

Function Calls

None

Variables

None

Stats

MD5 3c8c7c903e23cb528359f81774a9b021
Eval Count 0
Decode Time 82 ms