'elementor_new_post', 'post_type' => $post_type, ], admin_url('edit.php')); $new_post_url = add_query_arg('_wpnonce', wp_create_nonce('elementor_action_new_post'), $new_post_url); return $new_post_url; } /** * Get post autosave. * * Retrieve an autosave for any given post. * * @since 1.9.2 * @access public * @static * * @param int $post_id Post ID. * @param int $user_id Optional. User ID. Default is `0`. * * @return WPPost|false Post autosave or false. */ public static function getPostAutosave($post_id, $user_id = 0) { $autosave = wp_get_post_autosave($post_id, $user_id); return $autosave && strtotime($autosave->post_modified) > strtotime(get_post($post_id)->post_modified) ? $autosave : false; } /** * Is CPT supports custom templates. * * Whether the Custom Post Type supports templates. * * @since 2.0.0 * @access public * @static * * @return bool True is templates are supported, False otherwise. */ public static function isCptCustomTemplatesSupported(WPPost $post) { // return method_exists(wp_get_theme(), 'get_post_templates'); return UId::CONTENT !== $post->uid->id_type && $post->template_type !== 'product-quick-view' && $post->template_type !== 'product-miniature'; } /** * @since 2.1.2 * @access public * @static */ public static function arrayInject($array, $key, $insert) { $length = array_search($key, array_keys($array), true) + 1; return array_slice($array, 0, $length, true) + $insert + array_slice($array, $length, null, true); } /** * Render html attributes * * @access public * @static * @param array $attributes * * @return string */ public static function renderHtmlAttributes(array $attributes) { $rendered_attributes = []; foreach ($attributes as $attribute_key => $attribute_values) { if ([] === $attribute_values) { $rendered_attributes[] = $attribute_key; continue; } if (is_array($attribute_values)) { $attribute_values = implode(' ', $attribute_values); } $rendered_attributes[] = sprintf('%1$s="%2$s"', $attribute_key, esc_attr($attribute_values)); } return implode(' ', $rendered_attributes); } public static function getMetaViewport($context = '') { $meta_tag = ''; /** * Viewport meta tag. * * Filters the Elementor preview URL. * * @since 2.5.0 * * @param string $meta_tag Viewport meta tag. */ return apply_filters('elementor/template/viewport_tag', $meta_tag, $context); } // public static function printJsConfig($handle, $js_var, $config) - Use wp_localize_script instead }