PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 4.9.12.2
Virtue/Ascend/Pinnacle Toolkit v4.9.12.2
4.9.12.2 trunk 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.7 All 48 releases
← All changes | pagetemplater.php +42 -7 2.5 → 4.9.12.2 View file →
@@ -23,10 +23,13 @@
23 23 add_filter('wp_insert_post_data', array( $this, 'register_project_templates' ) );
24 24
25 25 add_filter('template_include', array( $this, 'view_project_template') );
26 26
27 + add_filter('theme_page_templates', array( $this, 'register_project_templates_update') );
28 +
29 + // Initialize template keys without translation (translation happens lazily)
27 30 $this->templates = array(
28 - 'template-contact.php' => __('Contact', 'kadencetoolkit'),
31 + 'template-contact.php' => 'Contact',
29 32 );
30 33
31 34 }
32 35
@@ -34,9 +37,9 @@
34 37
35 38 // Create the key used for the themes cache
36 39 $cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );
37 40
38 - $templates = wp_get_theme()->get_page_templates();
41 + $templates = wp_get_theme()->get_page_templates();
39 42
40 43 if ( empty( $templates ) ) {
41 44 $templates = array();
42 45 }
@@ -53,9 +56,21 @@
53 56
54 57 return $atts;
55 58
56 59 }
60 + public function register_project_templates_update($templates ) {
61 + if ( ! version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
62 + // Translate template names when they're actually needed (after init)
63 + $translated_templates = array();
64 + foreach ( $this->templates as $key => $label ) {
65 + $translated_templates[ $key ] = __( $label, 'virtue-toolkit' );
66 + }
67 + $templates = array_merge( $templates, $translated_templates );
57 68
69 + }
70 + return $templates;
71 +
72 + }
58 73 /**
59 74 * Checks if the template is assigned to the page
60 75 */
61 76 public function view_project_template( $template ) {
@@ -61,8 +76,10 @@
61 76 public function view_project_template( $template ) {
62 77
63 78 global $post;
64 79
80 + if ( !isset( $post ) ) return $template;
81 +
65 82 if (!isset($this->templates[get_post_meta( $post->ID, '_wp_page_template', true )] ) ) {
66 83
67 84 return $template;
68 85
@@ -82,9 +99,9 @@
82 99 }
83 100
84 101 }
85 102 $the_theme = wp_get_theme();
86 -if( ($the_theme->get( 'Name' ) == 'Pinnacle' || $the_theme->get( 'Template') == 'pinnacle') && ( $the_theme->get( 'Version') >= '1.0.6' ) ) {
103 +if( ($the_theme->get( 'Name' ) == 'Pinnacle' && $the_theme->get( 'Version') >= '1.0.6' ) || ($the_theme->get( 'Template') == 'pinnacle') ) {
87 104 add_action( 'plugins_loaded', array( 'Kadence_Page_Templater_Pinnacle', 'get_instance' ) );
88 105 }
89 106 class Kadence_Page_Templater_Virtue {
90 107
@@ -103,16 +120,19 @@
103 120 private function __construct() {
104 121
105 122 $this->templates = array();
106 123
107 - add_filter('page_attributes_dropdown_pages_args', array( $this, 'register_project_templates' ) );
124 + add_filter('wp_dropdown_pages', array( $this, 'register_project_templates' ) );
108 125
109 126 add_filter('wp_insert_post_data', array( $this, 'register_project_templates' ) );
110 127
111 128 add_filter('template_include', array( $this, 'view_project_template') );
112 129
130 + add_filter('theme_page_templates', array( $this, 'register_project_templates_update') );
131 +
132 + // Initialize template keys without translation (translation happens lazily)
113 133 $this->templates = array(
114 - 'page-contact.php' => __('Contact', 'kadencetoolkit'),
134 + 'page-contact.php' => 'Contact',
115 135 );
116 136
117 137 }
118 138
@@ -139,9 +159,22 @@
139 159
140 160 return $atts;
141 161
142 162 }
163 + public function register_project_templates_update($templates ) {
164 + if ( ! version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
165 + // Translate template names when they're actually needed (after init)
166 + $translated_templates = array();
167 + foreach ( $this->templates as $key => $label ) {
168 + $translated_templates[ $key ] = __( $label, 'virtue-toolkit' );
169 + }
170 + $templates = array_merge( $templates, $translated_templates );
143 171
172 + }
173 + return $templates;
174 +
175 + }
176 +
144 177 /**
145 178 * Checks if the template is assigned to the page
146 179 */
147 180 public function view_project_template( $template ) {
@@ -147,8 +180,10 @@
147 180 public function view_project_template( $template ) {
148 181
149 182 global $post;
150 183
184 + if ( !isset( $post ) ) return $template;
185 +
151 186 if (!isset($this->templates[get_post_meta( $post->ID, '_wp_page_template', true )] ) ) {
152 187
153 188 return $template;
154 189
@@ -168,7 +203,7 @@
168 203 }
169 204
170 205 }
171 206 $the_theme = wp_get_theme();
172 -if( ($the_theme->get( 'Name' ) == 'Virtue' || $the_theme->get( 'Template') == 'virtue') && ( $the_theme->get( 'Version') >= '2.3.5' ) ) {
207 +if( ($the_theme->get( 'Name' ) == 'Virtue' && $the_theme->get( 'Version') >= '2.3.5') || ($the_theme->get( 'Template') == 'virtue') ) {
173 208 add_action( 'plugins_loaded', array( 'Kadence_Page_Templater_Virtue', 'get_instance' ) );
174 -}
209 +}