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 +36 -5 3.1 → 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 ) {
@@ -105,16 +120,19 @@
105 120 private function __construct() {
106 121
107 122 $this->templates = array();
108 123
109 - add_filter('page_attributes_dropdown_pages_args', array( $this, 'register_project_templates' ) );
124 + add_filter('wp_dropdown_pages', array( $this, 'register_project_templates' ) );
110 125
111 126 add_filter('wp_insert_post_data', array( $this, 'register_project_templates' ) );
112 127
113 128 add_filter('template_include', array( $this, 'view_project_template') );
114 129
130 + add_filter('theme_page_templates', array( $this, 'register_project_templates_update') );
131 +
132 + // Initialize template keys without translation (translation happens lazily)
115 133 $this->templates = array(
116 - 'page-contact.php' => __('Contact', 'kadencetoolkit'),
134 + 'page-contact.php' => 'Contact',
117 135 );
118 136
119 137 }
120 138
@@ -141,9 +159,22 @@
141 159
142 160 return $atts;
143 161
144 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 );
145 171
172 + }
173 + return $templates;
174 +
175 + }
176 +
146 177 /**
147 178 * Checks if the template is assigned to the page
148 179 */
149 180 public function view_project_template( $template ) {
@@ -174,5 +205,5 @@
174 205 }
175 206 $the_theme = wp_get_theme();
176 207 if( ($the_theme->get( 'Name' ) == 'Virtue' && $the_theme->get( 'Version') >= '2.3.5') || ($the_theme->get( 'Template') == 'virtue') ) {
177 208 add_action( 'plugins_loaded', array( 'Kadence_Page_Templater_Virtue', 'get_instance' ) );
178 -}
209 +}