| @@ -35,8 +35,17 @@ | ||
| 35 | 35 | return wp_doing_ajax(); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | + * Is WP CLI. | |
| 40 | + * | |
| 41 | + * @return bool | |
| 42 | + */ | |
| 43 | + public static function is_wp_cli() { | |
| 44 | + return defined( 'WP_CLI' ) && WP_CLI; | |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 39 | 48 | * Is script debug. |
| 40 | 49 | * |
| 41 | 50 | * Whether script debug is enabled or not. |
| 42 | 51 | * |
| @@ -319,17 +328,24 @@ | ||
| 319 | 328 | * @access public |
| 320 | 329 | * @static |
| 321 | 330 | * |
| 322 | 331 | * @param string $post_type Optional. Post type slug. Default is 'page'. |
| 332 | + * @param string|null $template_type Optional. Query arg 'template_type'. Default is null. | |
| 323 | 333 | * |
| 324 | 334 | * @return string A URL for creating new post using Elementor. |
| 325 | 335 | */ |
| 326 | - public static function get_create_new_post_url( $post_type = 'page' ) { | |
| 327 | - $new_post_url = add_query_arg( [ | |
| 336 | + public static function get_create_new_post_url( $post_type = 'page', $template_type = null ) { | |
| 337 | + $query_args = [ | |
| 328 | 338 | 'action' => 'elementor_new_post', |
| 329 | 339 | 'post_type' => $post_type, |
| 330 | - ], admin_url( 'edit.php' ) ); | |
| 340 | + ]; | |
| 331 | 341 | |
| 342 | + if ( ! is_null( $template_type ) ) { | |
| 343 | + $query_args['template_type'] = $template_type; | |
| 344 | + } | |
| 345 | + | |
| 346 | + $new_post_url = add_query_arg( $query_args, admin_url( 'edit.php' ) ); | |
| 347 | + | |
| 332 | 348 | $new_post_url = add_query_arg( '_wpnonce', wp_create_nonce( 'elementor_action_new_post' ), $new_post_url ); |
| 333 | 349 | |
| 334 | 350 | return $new_post_url; |
| 335 | 351 | } |
| @@ -582,6 +598,29 @@ | ||
| 582 | 598 | } |
| 583 | 599 | } |
| 584 | 600 | |
| 585 | 601 | return false; |
| 602 | + } | |
| 603 | + | |
| 604 | + /** | |
| 605 | + * Change Submenu First Item Label | |
| 606 | + * | |
| 607 | + * Overwrite the label of the first submenu item of an admin menu item. | |
| 608 | + * | |
| 609 | + * Fired by `admin_menu` action. | |
| 610 | + * | |
| 611 | + * @since 3.1.0 | |
| 612 | + * | |
| 613 | + * @param $menu_slug | |
| 614 | + * @param $new_label | |
| 615 | + * @access public | |
| 616 | + */ | |
| 617 | + public static function change_submenu_first_item_label( $menu_slug, $new_label ) { | |
| 618 | + global $submenu; | |
| 619 | + | |
| 620 | + if ( isset( $submenu[ $menu_slug ] ) ) { | |
| 621 | + // @codingStandardsIgnoreStart | |
| 622 | + $submenu[ $menu_slug ][0][0] = $new_label; | |
| 623 | + // @codingStandardsIgnoreEnd | |
| 624 | + } | |
| 586 | 625 | } |
| 587 | 626 | } |