How to verify the license globally?
-
I added the following code to the index.php file in the theme, and it can prompt wp_die after verification.
But if this is written in every php file of the theme, is it too much trouble.
What kind of writing can be achieved: If the license is effective, the user will prompt the content of wp_die when visiting the website? functions.php? Can you give an example?
$api_params = array( 'slm_action' => 'slm_check', 'secret_key' => YOUR_SPECIAL_SECRET_KEY, 'license_key' =>get_option('sample_license_key'), ); // Send query to the license manager server $response = wp_remote_get(add_query_arg($api_params, YOUR_LICENSE_SERVER_URL), array('timeout' => 20, 'sslverify' => false)); $license_data = json_decode(wp_remote_retrieve_body($response)); if($license_data->result == 'success'){ get_header(); ?> <main id="primary" class="site-main"> <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <header> <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1> </header> <?php endif; /* Start the Loop */ while ( have_posts() ) : the_post(); /* * Include the Post-Type-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Type name) and that will be used instead. */ get_template_part( 'template-parts/content', get_post_type() ); endwhile; the_posts_navigation(); else : get_template_part( 'template-parts/content', 'none' ); endif; ?> </main><!-- #main --> <?php get_sidebar(); get_footer(); } else { wp_die('The authorization code has expired or is not activated! '); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to verify the license globally?’ is closed to new replies.