PluginProbe
SKT Templates – 100% Free Templates for Elementor & Gutenberg / trunk
SKT Templates – 100% Free Templates for Elementor & Gutenberg vtrunk
6.4.3 6.4.4 6.4.5 trunk 6.4.2
skt-templates / skt-templates.php

skt-templates.php in SKT Templates – 100% Free Templates for Elementor & Gutenberg trunk, at skt-templates.php

241 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: SKT Templates
4 * Plugin URI: https://www.sktthemes.org/shop/ready-to-import-wordpress-sites/
5 * Description: SKT Templates is an Elementor and Gutenberg themes library and allows you to select from over 100s of designs to choose from. All you need to do is view the demo and then select import and install. It takes care of the importing and allows you to edit the template from within your dashboard. It works with any popular theme or you can choose to use any theme from our <a href="https://www.sktthemes.org/product-category/free-wordpress-themes/" rel="nofollow ugc">SKT Themes free.</a> These templates allow you to import them into your existing website and edit them and use them to build professional websites. Importing a single page template is very easy and you can do it on your existing WordPress website as well.
6 * Version: 6.30.17
7 * Author: SKT Themes
8 * Author URI: https://www.sktthemes.org
9 * Text Domain: skt-templates
10 *
11 * @package SKT Templates
12 */
13
14 // If this file is called directly, abort.
15 if ( ! defined( 'WPINC' ) ) {
16 die;
17 }
18
19 if ( ! function_exists( 'st_fs' ) ) {
20 function st_fs() {
21 global $st_fs;
22 if ( ! isset( $st_fs ) ) {
23 require_once dirname(__FILE__) . '/freemius/start.php';
24 $st_fs = fs_dynamic_init( array(
25 'id' => '9291',
26 'slug' => 'skt-templates',
27 'type' => 'plugin',
28 'public_key' => 'pk_6353fc4cd917b8f995b2c4a5ddac7',
29 'is_premium' => false,
30 'has_addons' => false,
31 'has_paid_plans' => false,
32 'menu' => array(
33 'first-path' => 'admin.php?page=skt_template_directory',
34 'account' => false,
35 'support' => false,
36 ),
37 ) );
38 }
39 return $st_fs;
40 }
41 st_fs();
42 do_action( 'st_fs_loaded' );
43 }
44
45 /**
46 * Prevent the PHP 8.1+ "strip_tags(): Passing null" deprecation notice on the
47 * Freemius opt-in screen (and any admin page that doesn't register a title).
48 * Core wp-admin/admin-header.php runs strip_tags( $title ) on the global $title,
49 * which stays null on those pages. We only coerce it when it isn't already a
50 * string, so no real page title is ever changed.
51 */
52 add_action( 'current_screen', function () {
53 if ( ! isset( $GLOBALS['title'] ) || ! is_string( $GLOBALS['title'] ) ) {
54 $GLOBALS['title'] = '';
55 }
56 } );
57
58 // Set up the activation redirect
59 register_activation_hook( __FILE__, 'skt_templates_activate' );
60 add_action( 'admin_init', 'skt_templates_activation_redirect' );
61
62 function skt_templates_activate() {
63 if (
64 ( isset( $_REQUEST['action'] ) && 'activate-selected' === $_REQUEST['action'] ) &&
65 ( isset( $_POST['checked'] ) && count( $_POST['checked'] ) > 1 )
66 ) {
67 return;
68 }
69 add_option( 'skt_templates_activation_redirect', wp_get_current_user()->ID );
70 // Reset welcome banner so it shows again on each fresh activation.
71 $uid = get_current_user_id();
72 if ( $uid ) {
73 delete_user_meta( $uid, 'skt_welcome_dismissed' );
74 delete_user_meta( $uid, 'skt_templates_ignore_visit_dashboard_notice' );
75 }
76 }
77
78 /**
79 * Redirects the user after plugin activation.
80 */
81 function skt_templates_activation_redirect() {
82 if ( is_user_logged_in() && intval( get_option( 'skt_templates_activation_redirect', false ) ) === wp_get_current_user()->ID ) {
83 delete_option( 'skt_templates_activation_redirect' );
84 wp_safe_redirect( admin_url( '/admin.php?page=skt_template_directory' ) );
85 exit;
86 }
87 }
88
89 // Register custom rewrite rule and query var
90 add_action( 'init', 'skt_templates_register_xml_endpoint' );
91 function skt_templates_register_xml_endpoint() {
92 add_rewrite_tag( '%skt_templates_xml%', '1' );
93 add_rewrite_rule( '^skt-templates\.xml$', 'index.php?skt_templates_xml=1', 'top' );
94 }
95
96 // Register query var
97 add_filter( 'query_vars', 'skt_templates_add_query_var' );
98 function skt_templates_add_query_var( $vars ) {
99 $vars[] = 'skt_templates_xml';
100 return $vars;
101 }
102
103 // Auto flush rewrite rules once
104 add_action( 'init', 'skt_templates_maybe_flush_rules', 99 );
105 function skt_templates_maybe_flush_rules() {
106 if ( get_option( 'skt_templates_rules_flushed' ) === '1' ) {
107 return;
108 }
109 $rules = get_option( 'rewrite_rules' );
110 if ( ! isset( $rules['^skt-templates\.xml$'] ) ) {
111 flush_rewrite_rules();
112 update_option( 'skt_templates_rules_flushed', '1' );
113 }
114 }
115
116 // Reset flush flag on plugin deactivation
117 register_deactivation_hook( __FILE__, function() {
118 delete_option( 'skt_templates_rules_flushed' );
119 });
120
121 add_action( 'wp_head', 'skt_templates_add_link_to_head' );
122 function skt_templates_add_link_to_head() {
123 echo '<link rel="alternate" type="application/xml" href="' . esc_url( home_url( '/skt-templates.xml' ) ) . '" />';
124 }
125
126 // Render custom HTML output for /skt-templates.xml
127 add_action( 'template_redirect', 'skt_templates_render_custom_html' );
128 function skt_templates_render_custom_html() {
129 if ( get_query_var( 'skt_templates_xml' ) ) {
130 header( 'Content-Type: text/html; charset=utf-8' );
131 ?>
132 <!DOCTYPE html>
133 <html <?php language_attributes(); ?>>
134 <head>
135 <meta charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>" />
136 <meta name="viewport" content="width=device-width, initial-scale=1" />
137 <title><?php esc_html_e( 'Build Beautiful Websites with SKT Templates Plugin', 'skt-templates' ); ?></title>
138 <meta name="description" content="<?php esc_html_e( 'SKT Templates helps you build websites without writing any code. You can choose from over 100 designs. These designs are called templates.', 'skt-templates' ); ?>" />
139 <style>
140 body {
141 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
142 background: #fff;
143 color: #333;
144 line-height: 1.6;
145 margin: 0;
146 }
147 #skt-templates-description {
148 background: #0196d6;
149 color: #fff;
150 padding: 30px 20px;
151 }
152 #skt-templates-description h1 {
153 margin: 0;
154 font-size: 28px;
155 text-align: center;
156 }
157 #skt-templates-description p {
158 margin: 10px 0;
159 font-size: 16px;
160 }
161 #skt-templates-description a,
162 #skt-templates-content a {
163 color: #003be3;
164 text-decoration: none;
165 }
166 #skt-templates-description a:hover,
167 #skt-templates-content a:hover {
168 color: #f98315;
169 text-decoration: underline;
170 }
171 #skt-templates-content {
172 padding: 15px 20px;
173 background: #f9f9f9;
174 }
175 </style>
176 </head>
177 <body>
178 <div id="skt-templates-description">
179 <h1><?php esc_html_e( 'Build Beautiful Websites with SKT Templates Plugin', 'skt-templates' ); ?></h1>
180 </div>
181 <div id="skt-templates-content">
182 <center>
183 <?php
184 $paragraphs = array(
185 sprintf(
186 __( 'Visit the <a href="%1$s" target="_blank">SKT Themes</a> website to see all the options.', 'skt-templates' ),
187 esc_url( 'https://www.sktthemes.org/' )
188 ),
189 sprintf(
190 __( 'Kindly check our <a href="%1$s" target="_blank">WordPress themes bundle</a>.', 'skt-templates' ),
191 esc_url( 'https://www.sktthemes.org/shop/all-themes/' )
192 ),
193 sprintf(
194 __( 'Try our <a href="%1$s" target="_blank">free WordPress themes</a>.', 'skt-templates' ),
195 esc_url( 'https://www.sktthemes.org/product-category/free-wordpress-themes/' )
196 ),
197 );
198
199 foreach ( $paragraphs as $para ) {
200 echo '<p>' . wp_kses_post( $para ) . '</p>';
201 }
202 ?>
203 </center>
204 </div>
205 </body>
206 </html>
207 <?php
208 exit;
209 }
210 }
211
212 function run_skt_templates() {
213 define( 'SKTB_URL', plugins_url( '/', __FILE__ ) );
214 define( 'SKB_PATH', dirname( __FILE__ ) );
215 $plugin = new Skt_Templates();
216 $plugin->run();
217 $vendor_file = SKB_PATH . '/vendor/autoload.php';
218 if ( is_readable( $vendor_file ) ) {
219 require_once $vendor_file;
220 }
221 add_filter( 'sktthemes_sdk_products', function ( $products ) {
222 $products[] = __FILE__;
223 return $products;
224 } );
225 add_filter( 'sktthemes_companion_friendly_name', function( $name ) {
226 return 'SKT Templates';
227 } );
228 }
229
230 require 'class-autoloader.php';
231 SktAutoloader::set_plugins_path( plugin_dir_path( __DIR__ ) );
232 SktAutoloader::define_namespaces( array( 'Skt_Templates', 'SKTB', 'SKTB_Module' ) );
233 spl_autoload_register( array( 'SktAutoloader', 'loader' ) );
234
235 function skt_template_styles() {
236 wp_enqueue_style( 'templaters', plugin_dir_url( __FILE__ ) . 'css/templaters.css' );
237 }
238 add_action( 'wp_enqueue_scripts', 'skt_template_styles' );
239
240 // Start plugin
241 run_skt_templates();