Version Description
Download this release
Release Info
Developer | WPDevHQ |
Plugin | Page Templater For Elementor |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- assets/settings.php +61 -0
- custom-posttype-class.php +171 -0
- elementemplater-class.php +1 -4
- elementemplator.php +4 -1
- inc/custom-posttype-class.php +171 -0
- inc/settings.php +61 -0
- readme.txt +23 -4
- templates/sample-post-templates/fullwidth-single.php +13 -0
- templates/sample-post-templates/fullwidth-std-single.php +13 -0
assets/settings.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$tcp_options = get_option('elcpt_options');
|
3 |
+
$tcp_pts = isset($tcp_options['objects']) ? $tcp_options['objects'] : array();
|
4 |
+
?>
|
5 |
+
|
6 |
+
<div class="wrap">
|
7 |
+
<?php screen_icon('plugins'); ?>
|
8 |
+
<h2><?php _e('Post Type Template Settings', 'elementemplater'); ?></h2>
|
9 |
+
<?php if (isset($_GET['msg'])) : ?>
|
10 |
+
<div id="message" class="updated below-h2">
|
11 |
+
<?php if ($_GET['msg'] == 'update') : ?>
|
12 |
+
<p><?php _e('Settings Updated.','elementemplater'); ?></p>
|
13 |
+
<?php endif; ?>
|
14 |
+
</div>
|
15 |
+
<?php endif; ?>
|
16 |
+
|
17 |
+
<form method="post">
|
18 |
+
|
19 |
+
<?php if (function_exists('wp_nonce_field')) wp_nonce_field('nonce_elcpt'); ?>
|
20 |
+
|
21 |
+
<div id="tcp_select_objects">
|
22 |
+
|
23 |
+
<table class="form-table">
|
24 |
+
<tbody>
|
25 |
+
<tr valign="top">
|
26 |
+
<p><?php _e('Check to Apply Templates for Custom Post Types', 'elementemplater') ?></p>
|
27 |
+
</tr>
|
28 |
+
<tr>
|
29 |
+
<td>
|
30 |
+
<?php
|
31 |
+
$post_types = get_post_types(array(
|
32 |
+
'public' => true,
|
33 |
+
), 'objects');
|
34 |
+
|
35 |
+
foreach ($post_types as $post_type) {
|
36 |
+
if ($post_type->name == 'attachment' || $post_type->name == 'page')
|
37 |
+
continue;
|
38 |
+
?>
|
39 |
+
<label><input type="checkbox" name="objects[]" value="<?php echo $post_type->name; ?>" <?php
|
40 |
+
if (isset($tcp_pts) && is_array($tcp_pts)) {
|
41 |
+
if (in_array($post_type->name, $tcp_pts)) {
|
42 |
+
echo 'checked="checked"';
|
43 |
+
}
|
44 |
+
}
|
45 |
+
?>> <?php echo $post_type->label; ?></label><br>
|
46 |
+
<?php
|
47 |
+
}
|
48 |
+
?>
|
49 |
+
</td>
|
50 |
+
</tr>
|
51 |
+
</tbody>
|
52 |
+
</table>
|
53 |
+
|
54 |
+
</div>
|
55 |
+
|
56 |
+
<p class="submit">
|
57 |
+
<input id="submit" class="button button-primary" name="elcpt_submit" value="<?php _e('Save Changes', 'elementemplater'); ?>" type="submit">
|
58 |
+
</p>
|
59 |
+
|
60 |
+
</form>
|
61 |
+
</div>
|
custom-posttype-class.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WP_CustomTemplates {
|
4 |
+
|
5 |
+
private $elcpt_meta;
|
6 |
+
private $post_ID;
|
7 |
+
|
8 |
+
function __construct() {
|
9 |
+
$this->elcpt_meta = 'elcpt_template_name';
|
10 |
+
add_action( 'admin_menu', array($this,'elcpt_admin_menu') );
|
11 |
+
add_action('admin_init', array($this, 'elcpt_admin_init'));
|
12 |
+
add_action('admin_init', array($this, 'elcpt_update_options'));
|
13 |
+
add_action('save_post', array($this, 'elcpt_save_post'));
|
14 |
+
add_filter('body_class', array($this, 'elcpt_body_class'));
|
15 |
+
add_filter( 'single_template', array($this, 'elcpt_load_single_template'));
|
16 |
+
register_deactivation_hook( __FILE__, array($this, 'elcpt_uninstall'));
|
17 |
+
}
|
18 |
+
|
19 |
+
function elcpt_admin_menu() {
|
20 |
+
add_options_page(__('Post Type Template', 'elementemplater'), __('Post Type Template', 'elementemplater'), 'manage_options', 'elcpt-settings', array($this, 'elcpt_admin_page'));
|
21 |
+
}
|
22 |
+
|
23 |
+
function elcpt_admin_page() {
|
24 |
+
require ET_PATH . 'inc/settings.php';
|
25 |
+
}
|
26 |
+
|
27 |
+
function elcpt_admin_init() {
|
28 |
+
$cpt_options = get_option('elcpt_options');
|
29 |
+
|
30 |
+
if( isset($cpt_options['objects']) ) {
|
31 |
+
$post_types = apply_filters( 'elcpt_post_types', $cpt_options['objects'] );
|
32 |
+
foreach ( $post_types as $post_type )
|
33 |
+
add_meta_box(
|
34 |
+
'postparentdiv',
|
35 |
+
__( 'Custom Template', 'elementemplater' ),
|
36 |
+
array( $this, 'elcpt_post_template'),
|
37 |
+
$post_type,
|
38 |
+
'side',
|
39 |
+
'high'
|
40 |
+
);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
function elcpt_post_template( $post )
|
45 |
+
{
|
46 |
+
$this->post_ID = $post->ID;
|
47 |
+
|
48 |
+
$template_vars = array();
|
49 |
+
$templates = $this->elcpt_get_post_templates();
|
50 |
+
$custom_template = $this->elcpt_get_custom_post_template();
|
51 |
+
|
52 |
+
if ( $templates ) { ?>
|
53 |
+
<label class="hidden" for="page_template"><?php _e( 'Choose Template', 'elementemplater' ); ?></label>
|
54 |
+
<input type="hidden" name="cpt_current_template" value="1" />
|
55 |
+
<select name="custom_post_template" id="custom_post_template">
|
56 |
+
<option
|
57 |
+
value='default'
|
58 |
+
<?php
|
59 |
+
if ( ! $custom_template ) {
|
60 |
+
echo "selected='selected'";
|
61 |
+
}
|
62 |
+
?>><?php _e( 'Default Template' ); ?></option>
|
63 |
+
<?php foreach( $templates AS $filename => $name ) { ?>
|
64 |
+
<option
|
65 |
+
value='<?php echo $filename; ?>'
|
66 |
+
<?php
|
67 |
+
if ( $custom_template == $filename ) {
|
68 |
+
echo "selected='selected'";
|
69 |
+
}
|
70 |
+
?>><?php echo $name; ?></option>
|
71 |
+
<?php } ?>
|
72 |
+
</select>
|
73 |
+
<?php
|
74 |
+
}
|
75 |
+
else {
|
76 |
+
echo '<p>No Custom Templates Found!</p>';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
function elcpt_get_post_templates()
|
81 |
+
{
|
82 |
+
$theme = wp_get_theme();
|
83 |
+
$post_templates = array();
|
84 |
+
$files = (array) $theme->get_files( 'php', 1 );
|
85 |
+
foreach ( $files as $file => $full_path ) {
|
86 |
+
$headers = @get_file_data( $full_path, array( 'Post Template Name' => 'Post Template Name' ) );
|
87 |
+
if ( empty( $headers['Post Template Name'] ) )
|
88 |
+
continue;
|
89 |
+
$post_templates[ $file ] = $headers['Post Template Name'];
|
90 |
+
}
|
91 |
+
return $post_templates;
|
92 |
+
}
|
93 |
+
|
94 |
+
function elcpt_get_custom_post_template()
|
95 |
+
{
|
96 |
+
$custom_template = get_post_meta( $this->post_ID, $this->elcpt_meta, true );
|
97 |
+
return $custom_template;
|
98 |
+
}
|
99 |
+
|
100 |
+
function elcpt_set_custom_post_template( $template )
|
101 |
+
{
|
102 |
+
delete_post_meta( $this->post_ID, $this->elcpt_meta );
|
103 |
+
if ( ! $template || $template == 'default' ) return;
|
104 |
+
add_post_meta( $this->post_ID, $this->elcpt_meta, $template );
|
105 |
+
}
|
106 |
+
|
107 |
+
function elcpt_save_post( $post_ID )
|
108 |
+
{
|
109 |
+
$action_needed = (bool) @ $_POST[ 'cpt_current_template' ];
|
110 |
+
if ( ! $action_needed ) return;
|
111 |
+
|
112 |
+
$this->post_ID = $post_ID;
|
113 |
+
$template = (string) @ $_POST[ 'custom_post_template' ];
|
114 |
+
$template = stripslashes_deep($template);
|
115 |
+
$this->elcpt_set_custom_post_template( $template );
|
116 |
+
}
|
117 |
+
|
118 |
+
function elcpt_load_single_template( $template )
|
119 |
+
{
|
120 |
+
global $wp_query;
|
121 |
+
$this->post_ID = $wp_query->post->ID;
|
122 |
+
$template_file = $this->elcpt_get_custom_post_template();
|
123 |
+
|
124 |
+
if ( ! $template_file )
|
125 |
+
return $template;
|
126 |
+
|
127 |
+
if ( file_exists( trailingslashit( STYLESHEETPATH ) . $template_file ) )
|
128 |
+
return STYLESHEETPATH . DIRECTORY_SEPARATOR . $template_file;
|
129 |
+
else if ( file_exists( TEMPLATEPATH . DIRECTORY_SEPARATOR . $template_file ) )
|
130 |
+
return TEMPLATEPATH . DIRECTORY_SEPARATOR . $template_file;
|
131 |
+
|
132 |
+
return $template;
|
133 |
+
}
|
134 |
+
|
135 |
+
function elcpt_body_class( $classes ) {
|
136 |
+
if (!is_single()) {
|
137 |
+
return $classes;
|
138 |
+
}
|
139 |
+
$post_template = get_post_meta( get_the_ID(), 'elcpt_template_name', true );
|
140 |
+
if( !empty( $post_template) ) {
|
141 |
+
$classes[] = 'page-template';
|
142 |
+
$classes[] = 'page-template-' . str_replace( '.php', '-php', $post_template );
|
143 |
+
}
|
144 |
+
return $classes;
|
145 |
+
}
|
146 |
+
|
147 |
+
function elcpt_update_options() {
|
148 |
+
global $wpdb;
|
149 |
+
if (!isset($_POST['elcpt_submit']))
|
150 |
+
return false;
|
151 |
+
|
152 |
+
check_admin_referer('nonce_elcpt');
|
153 |
+
$input_options = array();
|
154 |
+
$input_options['objects'] = isset($_POST['objects']) ? $_POST['objects'] : '';
|
155 |
+
update_option('elcpt_options', $input_options);
|
156 |
+
wp_redirect('options-general.php?page=elcpt-settings&msg=update');
|
157 |
+
}
|
158 |
+
|
159 |
+
function elcpt_uninstall()
|
160 |
+
{
|
161 |
+
delete_option('elcpt_options');
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Instantiate the plugin
|
167 |
+
*
|
168 |
+
* @global
|
169 |
+
**/
|
170 |
+
$cpt_obj = new WP_CustomTemplates();
|
171 |
+
?>
|
elementemplater-class.php
CHANGED
@@ -48,7 +48,6 @@ class ElemenTemplater {
|
|
48 |
array( $this, 'register_project_templates' )
|
49 |
);
|
50 |
|
51 |
-
|
52 |
// Add a filter to the save post to inject out template into the page cache
|
53 |
add_filter(
|
54 |
'wp_insert_post_data',
|
@@ -63,13 +62,11 @@ class ElemenTemplater {
|
|
63 |
array( $this, 'view_project_template')
|
64 |
);
|
65 |
|
66 |
-
|
67 |
// Add your templates to this array.
|
68 |
$this->templates = array(
|
69 |
'templates/builder-fullwidth.php' => __( 'Elementor Fullwidth Blank', 'elementemplater' ),
|
70 |
'templates/builder-fullwidth-std.php' => __( 'Elementor Fullwidth Standard', 'elementemplater' ),
|
71 |
-
);
|
72 |
-
|
73 |
}
|
74 |
|
75 |
/**
|
48 |
array( $this, 'register_project_templates' )
|
49 |
);
|
50 |
|
|
|
51 |
// Add a filter to the save post to inject out template into the page cache
|
52 |
add_filter(
|
53 |
'wp_insert_post_data',
|
62 |
array( $this, 'view_project_template')
|
63 |
);
|
64 |
|
|
|
65 |
// Add your templates to this array.
|
66 |
$this->templates = array(
|
67 |
'templates/builder-fullwidth.php' => __( 'Elementor Fullwidth Blank', 'elementemplater' ),
|
68 |
'templates/builder-fullwidth-std.php' => __( 'Elementor Fullwidth Standard', 'elementemplater' ),
|
69 |
+
);
|
|
|
70 |
}
|
71 |
|
72 |
/**
|
elementemplator.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Elementor Templater: ElemenTemplator
|
4 |
* Plugin URI: http://www.wpdevhq.com/plugins/elementor-templator
|
5 |
* Description: A helper plugin for users of Elementor Pagebuilder.
|
6 |
-
* Version: 1.0.
|
7 |
* Author: WPDevHQ
|
8 |
* Author URI: http://www.wpdevhq.com/
|
9 |
* Requires at least: 4.4
|
@@ -28,5 +28,8 @@ define( 'ET_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
|
|
28 |
/* ElemenTemplater Class */
|
29 |
require_once( ET_PATH . 'elementemplater-class.php' );
|
30 |
|
|
|
|
|
|
|
31 |
/* Template Functions */
|
32 |
require_once( ET_PATH . 'inc/elementemplater-functions.php' );
|
3 |
* Plugin Name: Elementor Templater: ElemenTemplator
|
4 |
* Plugin URI: http://www.wpdevhq.com/plugins/elementor-templator
|
5 |
* Description: A helper plugin for users of Elementor Pagebuilder.
|
6 |
+
* Version: 1.0.2
|
7 |
* Author: WPDevHQ
|
8 |
* Author URI: http://www.wpdevhq.com/
|
9 |
* Requires at least: 4.4
|
28 |
/* ElemenTemplater Class */
|
29 |
require_once( ET_PATH . 'elementemplater-class.php' );
|
30 |
|
31 |
+
/* Custom Post Template Class */
|
32 |
+
require_once( ET_PATH . 'custom-posttype-class.php' );
|
33 |
+
|
34 |
/* Template Functions */
|
35 |
require_once( ET_PATH . 'inc/elementemplater-functions.php' );
|
inc/custom-posttype-class.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WP_CustomTemplates {
|
4 |
+
|
5 |
+
private $wptcp_meta;
|
6 |
+
private $post_ID;
|
7 |
+
|
8 |
+
function __construct() {
|
9 |
+
$this->wptcp_meta = 'wptcp_template_name';
|
10 |
+
add_action( 'admin_menu', array($this,'wptcp_admin_menu') );
|
11 |
+
add_action('admin_init', array($this, 'wptcp_admin_init'));
|
12 |
+
add_action('admin_init', array($this, 'wptcp_update_options'));
|
13 |
+
add_action('save_post', array($this, 'wptcp_save_post'));
|
14 |
+
add_filter('body_class', array($this, 'wptcp_body_class'));
|
15 |
+
add_filter( 'single_template', array($this, 'wptcp_load_single_template'));
|
16 |
+
register_deactivation_hook( __FILE__, array($this, 'wptcp_uninstall'));
|
17 |
+
}
|
18 |
+
|
19 |
+
function wptcp_admin_menu() {
|
20 |
+
add_options_page(__('Post Type Template', 'elementemplater'), __('Post Type Template', 'elementemplater'), 'manage_options', 'wptcp-settings', array($this, 'wptcp_admin_page'));
|
21 |
+
}
|
22 |
+
|
23 |
+
function wptcp_admin_page() {
|
24 |
+
require ET_PATH . 'inc/settings.php';
|
25 |
+
}
|
26 |
+
|
27 |
+
function wptcp_admin_init() {
|
28 |
+
$tcp_options = get_option('wptcp_options');
|
29 |
+
|
30 |
+
if( isset($tcp_options['objects']) ) {
|
31 |
+
$post_types = apply_filters( 'wptcp_post_types', $tcp_options['objects'] );
|
32 |
+
foreach ( $post_types as $post_type )
|
33 |
+
add_meta_box(
|
34 |
+
'postparentdiv',
|
35 |
+
__( 'Custom Template', 'elementemplater' ),
|
36 |
+
array( $this, 'wptcp_post_template'),
|
37 |
+
$post_type,
|
38 |
+
'side',
|
39 |
+
'high'
|
40 |
+
);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
function wptcp_post_template( $post )
|
45 |
+
{
|
46 |
+
$this->post_ID = $post->ID;
|
47 |
+
|
48 |
+
$template_vars = array();
|
49 |
+
$templates = $this->wptcp_get_post_templates();
|
50 |
+
$custom_template = $this->wptcp_get_custom_post_template();
|
51 |
+
|
52 |
+
if ( $templates ) { ?>
|
53 |
+
<label class="hidden" for="page_template"><?php _e( 'Choose Template', 'elementemplater' ); ?></label>
|
54 |
+
<input type="hidden" name="tcp_current_template" value="1" />
|
55 |
+
<select name="custom_post_template" id="custom_post_template">
|
56 |
+
<option
|
57 |
+
value='default'
|
58 |
+
<?php
|
59 |
+
if ( ! $custom_template ) {
|
60 |
+
echo "selected='selected'";
|
61 |
+
}
|
62 |
+
?>><?php _e( 'Default Template' ); ?></option>
|
63 |
+
<?php foreach( $templates AS $filename => $name ) { ?>
|
64 |
+
<option
|
65 |
+
value='<?php echo $filename; ?>'
|
66 |
+
<?php
|
67 |
+
if ( $custom_template == $filename ) {
|
68 |
+
echo "selected='selected'";
|
69 |
+
}
|
70 |
+
?>><?php echo $name; ?></option>
|
71 |
+
<?php } ?>
|
72 |
+
</select>
|
73 |
+
<?php
|
74 |
+
}
|
75 |
+
else {
|
76 |
+
echo '<p>No Custom Templates Found!</p>';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
function wptcp_get_post_templates()
|
81 |
+
{
|
82 |
+
$theme = wp_get_theme();
|
83 |
+
$post_templates = array();
|
84 |
+
$files = (array) $theme->get_files( 'php', 1 );
|
85 |
+
foreach ( $files as $file => $full_path ) {
|
86 |
+
$headers = @get_file_data( $full_path, array( 'Post Template Name' => 'Post Template Name' ) );
|
87 |
+
if ( empty( $headers['Post Template Name'] ) )
|
88 |
+
continue;
|
89 |
+
$post_templates[ $file ] = $headers['Post Template Name'];
|
90 |
+
}
|
91 |
+
return $post_templates;
|
92 |
+
}
|
93 |
+
|
94 |
+
function wptcp_get_custom_post_template()
|
95 |
+
{
|
96 |
+
$custom_template = get_post_meta( $this->post_ID, $this->wptcp_meta, true );
|
97 |
+
return $custom_template;
|
98 |
+
}
|
99 |
+
|
100 |
+
function wptcp_set_custom_post_template( $template )
|
101 |
+
{
|
102 |
+
delete_post_meta( $this->post_ID, $this->wptcp_meta );
|
103 |
+
if ( ! $template || $template == 'default' ) return;
|
104 |
+
add_post_meta( $this->post_ID, $this->wptcp_meta, $template );
|
105 |
+
}
|
106 |
+
|
107 |
+
function wptcp_save_post( $post_ID )
|
108 |
+
{
|
109 |
+
$action_needed = (bool) @ $_POST[ 'tcp_current_template' ];
|
110 |
+
if ( ! $action_needed ) return;
|
111 |
+
|
112 |
+
$this->post_ID = $post_ID;
|
113 |
+
$template = (string) @ $_POST[ 'custom_post_template' ];
|
114 |
+
$template = stripslashes_deep($template);
|
115 |
+
$this->wptcp_set_custom_post_template( $template );
|
116 |
+
}
|
117 |
+
|
118 |
+
function wptcp_load_single_template( $template )
|
119 |
+
{
|
120 |
+
global $wp_query;
|
121 |
+
$this->post_ID = $wp_query->post->ID;
|
122 |
+
$template_file = $this->wptcp_get_custom_post_template();
|
123 |
+
|
124 |
+
if ( ! $template_file )
|
125 |
+
return $template;
|
126 |
+
|
127 |
+
if ( file_exists( trailingslashit( STYLESHEETPATH ) . $template_file ) )
|
128 |
+
return STYLESHEETPATH . DIRECTORY_SEPARATOR . $template_file;
|
129 |
+
else if ( file_exists( TEMPLATEPATH . DIRECTORY_SEPARATOR . $template_file ) )
|
130 |
+
return TEMPLATEPATH . DIRECTORY_SEPARATOR . $template_file;
|
131 |
+
|
132 |
+
return $template;
|
133 |
+
}
|
134 |
+
|
135 |
+
function wptcp_body_class( $classes ) {
|
136 |
+
if (!is_single()) {
|
137 |
+
return $classes;
|
138 |
+
}
|
139 |
+
$post_template = get_post_meta( get_the_ID(), 'wptcp_template_name', true );
|
140 |
+
if( !empty( $post_template) ) {
|
141 |
+
$classes[] = 'page-template';
|
142 |
+
$classes[] = 'page-template-' . str_replace( '.php', '-php', $post_template );
|
143 |
+
}
|
144 |
+
return $classes;
|
145 |
+
}
|
146 |
+
|
147 |
+
function wptcp_update_options() {
|
148 |
+
global $wpdb;
|
149 |
+
if (!isset($_POST['wptcp_submit']))
|
150 |
+
return false;
|
151 |
+
|
152 |
+
check_admin_referer('nonce_wptcp');
|
153 |
+
$input_options = array();
|
154 |
+
$input_options['objects'] = isset($_POST['objects']) ? $_POST['objects'] : '';
|
155 |
+
update_option('wptcp_options', $input_options);
|
156 |
+
wp_redirect('options-general.php?page=wptcp-settings&msg=update');
|
157 |
+
}
|
158 |
+
|
159 |
+
function wptcp_uninstall()
|
160 |
+
{
|
161 |
+
delete_option('wptcp_options');
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Instantiate the plugin
|
167 |
+
*
|
168 |
+
* @global
|
169 |
+
**/
|
170 |
+
$tcp_obj = new WP_CustomTemplates();
|
171 |
+
?>
|
inc/settings.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$cpt_options = get_option('elcpt_options');
|
3 |
+
$cpt_pts = isset($cpt_options['objects']) ? $cpt_options['objects'] : array();
|
4 |
+
?>
|
5 |
+
|
6 |
+
<div class="wrap">
|
7 |
+
<?php screen_icon('plugins'); ?>
|
8 |
+
<h2><?php _e('Post Type Template Settings', 'elementemplater'); ?></h2>
|
9 |
+
<?php if (isset($_GET['msg'])) : ?>
|
10 |
+
<div id="message" class="updated below-h2">
|
11 |
+
<?php if ($_GET['msg'] == 'update') : ?>
|
12 |
+
<p><?php _e('Settings Updated.','elementemplater'); ?></p>
|
13 |
+
<?php endif; ?>
|
14 |
+
</div>
|
15 |
+
<?php endif; ?>
|
16 |
+
|
17 |
+
<form method="post">
|
18 |
+
|
19 |
+
<?php if (function_exists('wp_nonce_field')) wp_nonce_field('nonce_elcpt'); ?>
|
20 |
+
|
21 |
+
<div id="cpt_select_objects">
|
22 |
+
|
23 |
+
<table class="form-table">
|
24 |
+
<tbody>
|
25 |
+
<tr valign="top">
|
26 |
+
<p><?php _e('Check to Apply Templates for Custom Post Types', 'elementemplater') ?></p>
|
27 |
+
</tr>
|
28 |
+
<tr>
|
29 |
+
<td>
|
30 |
+
<?php
|
31 |
+
$post_types = get_post_types(array(
|
32 |
+
'public' => true,
|
33 |
+
), 'objects');
|
34 |
+
|
35 |
+
foreach ($post_types as $post_type) {
|
36 |
+
if ($post_type->name == 'attachment' || $post_type->name == 'page')
|
37 |
+
continue;
|
38 |
+
?>
|
39 |
+
<label><input type="checkbox" name="objects[]" value="<?php echo $post_type->name; ?>" <?php
|
40 |
+
if (isset($cpt_pts) && is_array($cpt_pts)) {
|
41 |
+
if (in_array($post_type->name, $cpt_pts)) {
|
42 |
+
echo 'checked="checked"';
|
43 |
+
}
|
44 |
+
}
|
45 |
+
?>> <?php echo $post_type->label; ?></label><br>
|
46 |
+
<?php
|
47 |
+
}
|
48 |
+
?>
|
49 |
+
</td>
|
50 |
+
</tr>
|
51 |
+
</tbody>
|
52 |
+
</table>
|
53 |
+
|
54 |
+
</div>
|
55 |
+
|
56 |
+
<p class="submit">
|
57 |
+
<input id="submit" class="button button-primary" name="elcpt_submit" value="<?php _e('Save Changes', 'elementemplater'); ?>" type="submit">
|
58 |
+
</p>
|
59 |
+
|
60 |
+
</form>
|
61 |
+
</div>
|
readme.txt
CHANGED
@@ -3,22 +3,27 @@ Contributors: WPDevHQ
|
|
3 |
Tags: elementor, pagebuilder, page builder, page builder template, page builder templates, actions, storefront, twentysixteen, genesis, template builder, builder templates
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.6
|
6 |
-
Stable tag: 1.0.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
A helper plugin for users of Elementor Page Builder
|
11 |
|
12 |
== Description ==
|
13 |
-
This plugin does one and one thing only - adds page templates (plus css) to any theme for use with the [Elementor Page Builder](https://wordpress.org/plugins/elementor/)
|
|
|
14 |
Now includes support for custom menu to be used for anchor points on the full width blank template.
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
- Template 1: Full width with header and footer : Builder Fullwidth Standard
|
18 |
- Template 2: Full width and no header or footer : Builder Fullwidth Blank
|
19 |
|
20 |
== Supported Themes ==
|
21 |
-
The following themes are currently supported out of the box - if your desired theme is not list you may need to add some custom css.
|
22 |
* [Actions](https://wordpress.org/themes/actions/) - by WPDevHQ
|
23 |
* [Edge](https://wordpress.org/themes/edge/) - By themefreesia
|
24 |
* [Experon](https://wordpress.org/themes/experon/) - ThinkUpThemes
|
@@ -64,6 +69,17 @@ Anchors a point on a template that are attached to a specific menu item - upon c
|
|
64 |
**How do I use this new feature?**
|
65 |
Please visit [Build With Elementor: Anchor Menus](http://buildwithelementor.com/custom-menu/) to get an over view of the it all works.
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
== Screenshots ==
|
68 |
|
69 |
1. Fullwidth with Header and Footer
|
@@ -72,6 +88,9 @@ Please visit [Build With Elementor: Anchor Menus](http://buildwithelementor.com/
|
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
75 |
= 1.0.1 =
|
76 |
* NEW: Added support to use the custom menu widget on full width blank template - ideal for anchor menus
|
77 |
|
3 |
Tags: elementor, pagebuilder, page builder, page builder template, page builder templates, actions, storefront, twentysixteen, genesis, template builder, builder templates
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.6
|
6 |
+
Stable tag: 1.0.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
A helper plugin for users of Elementor Page Builder
|
11 |
|
12 |
== Description ==
|
13 |
+
This plugin does one and one thing only - adds page templates (plus css) to any theme for use with the [Elementor Page Builder](https://wordpress.org/plugins/elementor/)
|
14 |
+
|
15 |
Now includes support for custom menu to be used for anchor points on the full width blank template.
|
16 |
|
17 |
+
NEW: Support for custom post templates now included. Your theme/child theme must have custom post templates with in it for this function to work.
|
18 |
+
|
19 |
+
See the [FAQ](https://wordpress.org/plugins/elementor-templater/faq/) for details and a download link for an Actions Elementor ready child theme.
|
20 |
+
|
21 |
+
Initial version only contains 2 templates
|
22 |
- Template 1: Full width with header and footer : Builder Fullwidth Standard
|
23 |
- Template 2: Full width and no header or footer : Builder Fullwidth Blank
|
24 |
|
25 |
== Supported Themes ==
|
26 |
+
The following themes are currently supported out of the box - if your desired theme is not list you may need to add some custom css.
|
27 |
* [Actions](https://wordpress.org/themes/actions/) - by WPDevHQ
|
28 |
* [Edge](https://wordpress.org/themes/edge/) - By themefreesia
|
29 |
* [Experon](https://wordpress.org/themes/experon/) - ThinkUpThemes
|
69 |
**How do I use this new feature?**
|
70 |
Please visit [Build With Elementor: Anchor Menus](http://buildwithelementor.com/custom-menu/) to get an over view of the it all works.
|
71 |
|
72 |
+
** I've update to version 1.0.2 but don't see the templates for posts, why?**
|
73 |
+
As with the current state of WordPress, custom post templates are only supported via themes and not plugins.
|
74 |
+
To be able to use the new feature your theme needs to have a template with the tag "Post Template Name: TemplateName".
|
75 |
+
If your theme does not have any templates you can copy the sample templates provided in the folder templates/sample-post-templates in this plugin.
|
76 |
+
To understand how this works please download the free child theme for Actions from here: [Actions Child](http://buildwithelementor.com/blog/actions-elementor-child-theme/) - this can be used out of the box if desired.
|
77 |
+
|
78 |
+
The above is subject to change with WordPress 4.7 as it will support custom post templates out of the box. Further details will be available near the time of the release.
|
79 |
+
|
80 |
+
**I've done the above but still no templates meta box on my edit screen**
|
81 |
+
Please visit the settings page located at Dasboard >> Settings >> Post Type Template to enable for your available Post Types.
|
82 |
+
|
83 |
== Screenshots ==
|
84 |
|
85 |
1. Fullwidth with Header and Footer
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
=1.0.2 =
|
92 |
+
* NEW: Added support for custom post templates - supports all custom post types including Elementor Library.
|
93 |
+
|
94 |
= 1.0.1 =
|
95 |
* NEW: Added support to use the custom menu widget on full width blank template - ideal for anchor menus
|
96 |
|
templates/sample-post-templates/fullwidth-single.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Post Template Name: Post Fullwidth Blank
|
4 |
+
*
|
5 |
+
* The second template used to demonstrate how to include the template
|
6 |
+
* using this plugin.
|
7 |
+
*
|
8 |
+
* @package ET
|
9 |
+
* @since 1.0.0
|
10 |
+
* @version 1.0.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
elementor_blankpb();
|
templates/sample-post-templates/fullwidth-std-single.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Post Template Name: Post Fullwidth Standard
|
4 |
+
*
|
5 |
+
* A template used to demonstrate how to include the template
|
6 |
+
* using this plugin.
|
7 |
+
*
|
8 |
+
* @package ET
|
9 |
+
* @since 1.0.0
|
10 |
+
* @version 1.0.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
elementor_pagebuilder();
|