Skip to content

Instantly share code, notes, and snippets.

@heyfletch
Last active June 12, 2024 19:15
Show Gist options
  • Select an option

  • Save heyfletch/7c59d1c0c9c56cbad51ef80290d86df7 to your computer and use it in GitHub Desktop.

Select an option

Save heyfletch/7c59d1c0c9c56cbad51ef80290d86df7 to your computer and use it in GitHub Desktop.

Revisions

  1. heyfletch revised this gist Sep 11, 2019. No changes.
  2. heyfletch revised this gist Sep 11, 2019. No changes.
  3. heyfletch revised this gist Sep 11, 2019. 1 changed file with 22 additions and 18 deletions.
    40 changes: 22 additions & 18 deletions make-elementor-default-editor.php
    Original file line number Diff line number Diff line change
    @@ -16,29 +16,33 @@
    add_filter('get_edit_post_link', 'fd_make_elementor_default_edit_link', 10, 3 );
    function fd_make_elementor_default_edit_link($link, $post_id, $context) {

    // Get current screen parameters
    $screen = get_current_screen();
    // Only relevant in the admin, checks for function that is occasionally missing
    if ( is_admin() && function_exists('get_current_screen') ) {

    //check if $screen is object otherwise we may be on an admin page where get_current_screen isn't defined
    if( !is_object($screen) )
    return;
    // Get current screen parameters
    $screen = get_current_screen();

    // Post Types to Edit with Elementor
    $post_types_for_elementor = array(
    'page',
    'post',
    'elementor_library',
    );
    //check if $screen is object otherwise we may be on an admin page where get_current_screen isn't defined
    if( !is_object($screen) )
    return;

    // When we are on a specified post type screen
    if ( in_array( $screen->post_type, $post_types_for_elementor ) && $context == 'display' ) {
    // Post Types to Edit with Elementor
    $post_types_for_elementor = array(
    'page',
    'post',
    'elementor_library',
    );

    // When we are on a specified post type screen
    if ( in_array( $screen->post_type, $post_types_for_elementor ) && $context == 'display' ) {

    // Build the Elementor editor link
    $elementor_editor_link = admin_url( 'post.php?post=' . $post_id . '&action=elementor' );
    // Build the Elementor editor link
    $elementor_editor_link = admin_url( 'post.php?post=' . $post_id . '&action=elementor' );

    return $elementor_editor_link;
    } else {
    return $link;
    return $elementor_editor_link;
    } else {
    return $link;
    }
    }
    }

  4. heyfletch revised this gist Mar 21, 2019. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions make-elementor-default-editor.php
    Original file line number Diff line number Diff line change
    @@ -20,8 +20,8 @@ function fd_make_elementor_default_edit_link($link, $post_id, $context) {
    $screen = get_current_screen();

    //check if $screen is object otherwise we may be on an admin page where get_current_screen isn't defined
    if( !is_object($screen) )
    return;
    if( !is_object($screen) )
    return;

    // Post Types to Edit with Elementor
    $post_types_for_elementor = array(
    @@ -52,9 +52,9 @@ function fd_add_back_default_edit_link( $actions, $post ) {

    // Rewrite the normal Edit link
    $actions['edit'] =
    sprintf( '<a href="%1$s">%2$s</a>',
    esc_url( $elementor_edit_url ),
    esc_html( __( 'Default WordPress Editor', 'elementor' ) )
    sprintf( '<a href="%1$s">%2$s</a>',
    esc_url( $elementor_edit_url ),
    esc_html( __( 'Default WordPress Editor', 'elementor' ) )
    );

    return $actions;
    @@ -66,8 +66,8 @@ function fd_add_back_default_edit_link( $actions, $post ) {
    add_filter( 'post_row_actions', 'fd_remove_default_edit_with_elementor', 99, 2 );
    function fd_remove_default_edit_with_elementor( $actions, $post ) {

    // Rewrite the normal Edit link
    unset( $actions['edit_with_elementor'] );
    // Rewrite the normal Edit link
    unset( $actions['edit_with_elementor'] );

    return $actions;
    }
  5. heyfletch revised this gist Mar 21, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion make-elementor-default-editor.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * You can revert by clicking the "Back to WordPress Editor" button
    *
    * Author: Joe Fletcher, https://fletcherdigital.com
    * URL: https://gist.github.com/heyfletch/7c59d1c0c9c56cbad51ef80290d86df7
    * URL: https://gist.github.com/heyfletch/7c59d1c0c9c56cbad51ef80290d86df7
    * Credit: mjakic https://wordpress.stackexchange.com/questions/178416/how-to-change-the-title-url-on-the-edit-post-screen
    * Credit: Aurovrata Venet https://developer.wordpress.org/reference/hooks/post_row_actions/
    */
  6. heyfletch revised this gist Mar 21, 2019. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions make-elementor-default-editor.php
    Original file line number Diff line number Diff line change
    @@ -7,16 +7,21 @@
    * You can revert by clicking the "Back to WordPress Editor" button
    *
    * Author: Joe Fletcher, https://fletcherdigital.com
    * URL: https://gist.github.com/heyfletch/7c59d1c0c9c56cbad51ef80290d86df7
    * Credit: mjakic https://wordpress.stackexchange.com/questions/178416/how-to-change-the-title-url-on-the-edit-post-screen
    * Credit: Aurovrata Venet https://developer.wordpress.org/reference/hooks/post_row_actions/
    */

    /** Replace hyperlink in post titles on Page, Post, or Template lists with Elementor's editor link */
    add_filter('get_edit_post_link', 'fd_get_edit_post_link', 10, 3 );
    function fd_get_edit_post_link($link, $post_id, $context) {
    add_filter('get_edit_post_link', 'fd_make_elementor_default_edit_link', 10, 3 );
    function fd_make_elementor_default_edit_link($link, $post_id, $context) {

    // Get current screen parameters
    $scr = get_current_screen();
    $screen = get_current_screen();

    //check if $screen is object otherwise we may be on an admin page where get_current_screen isn't defined
    if( !is_object($screen) )
    return;

    // Post Types to Edit with Elementor
    $post_types_for_elementor = array(
    @@ -26,7 +31,7 @@ function fd_get_edit_post_link($link, $post_id, $context) {
    );

    // When we are on a specified post type screen
    if ( in_array( $scr->post_type, $post_types_for_elementor ) && $context == 'display' ) {
    if ( in_array( $screen->post_type, $post_types_for_elementor ) && $context == 'display' ) {

    // Build the Elementor editor link
    $elementor_editor_link = admin_url( 'post.php?post=' . $post_id . '&action=elementor' );
  7. heyfletch revised this gist Feb 21, 2019. 1 changed file with 19 additions and 21 deletions.
    40 changes: 19 additions & 21 deletions make-elementor-default-editor.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    <?php

    /**
    * Make Elementor the default editor, not the WordPress Editor (Gutenberg or Classic)
    * Clicking the page title will take you to the Elementor editor directly
    * Even non-Elementor-edited pages will become Elementor-edited pages now
    * You can revert by clicking the "Back to WordPress Editor" button
    *
    * Author: Joe Fletcher, https://fletcherdigital.com
    * Author: Joe Fletcher, https://fletcherdigital.com
    * Credit: mjakic https://wordpress.stackexchange.com/questions/178416/how-to-change-the-title-url-on-the-edit-post-screen
    * Credit: Aurovrata Venet https://developer.wordpress.org/reference/hooks/post_row_actions/
    */
    @@ -24,7 +26,7 @@ function fd_get_edit_post_link($link, $post_id, $context) {
    );

    // When we are on a specified post type screen
    if ( in_array( $scr->post_type, $post_types_for_elementor ) && $context == 'display') {
    if ( in_array( $scr->post_type, $post_types_for_elementor ) && $context == 'display' ) {

    // Build the Elementor editor link
    $elementor_editor_link = admin_url( 'post.php?post=' . $post_id . '&action=elementor' );
    @@ -35,41 +37,37 @@ function fd_get_edit_post_link($link, $post_id, $context) {
    }
    }

    /** Add back the default Edit link in Page and Post list rows */
    /** Add back the default Edit link action in Page and Post list rows */
    add_filter( 'page_row_actions', 'fd_add_back_default_edit_link', 10, 2 );
    add_filter( 'post_row_actions', 'fd_add_back_default_edit_link', 10, 2 );
    function fd_add_back_default_edit_link( $actions, $post ) {

    // Build the Elementor edit URL
    $elementor_edit_url = admin_url( 'post.php?post=' . $post->ID . '&action=edit' );
    // Build the Elementor edit URL
    $elementor_edit_url = admin_url( 'post.php?post=' . $post->ID . '&action=edit' );

    // Rewrite the normal Edit link
    $actions['edit'] =
    sprintf( '<a href="%1$s">%2$s</a>',
    esc_url( $elementor_edit_url ),
    esc_html( __( 'Default WordPress Editor', 'elementor' ) )
    );
    // Rewrite the normal Edit link
    $actions['edit'] =
    sprintf( '<a href="%1$s">%2$s</a>',
    esc_url( $elementor_edit_url ),
    esc_html( __( 'Default WordPress Editor', 'elementor' ) )
    );

    return $actions;
    return $actions;
    }



    /** Repeat above for post_row_actions */


    /** (optional) Remove "Edit with Elementor" link added by Elementor itself */
    /** (optional) Remove redundant "Edit with Elementor" link added by Elementor itself */
    add_filter( 'page_row_actions', 'fd_remove_default_edit_with_elementor', 99, 2 );
    add_filter( 'post_row_actions', 'fd_remove_default_edit_with_elementor', 99, 2 );
    function fd_remove_default_edit_with_elementor( $actions, $post ) {

    // Rewrite the normal Edit link
    unset($actions['edit_with_elementor']);
    // Rewrite the normal Edit link
    unset( $actions['edit_with_elementor'] );

    return $actions;
    return $actions;
    }

    /** Alternative: Rewrite just the Edit link, and leave the page title as original */
    /** Alternative: Rewrite just the Edit link, and leave the page title as original */
    /** Rewrite the normal Edit link on lists of Pages and replace it with Elementor's edit link */
    // add_filter( 'page_row_actions', 'fd_elementor_modify_list_row_actions', 10, 2 );
    // add_filter( 'post_row_actions', 'fd_elementor_modify_list_row_actions', 10, 2 );
  8. heyfletch created this gist Feb 21, 2019.
    89 changes: 89 additions & 0 deletions make-elementor-default-editor.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    /**
    * Make Elementor the default editor, not the WordPress Editor (Gutenberg or Classic)
    * Clicking the page title will take you to the Elementor editor directly
    * Even non-Elementor-edited pages will become Elementor-edited pages now
    * You can revert by clicking the "Back to WordPress Editor" button
    *
    * Author: Joe Fletcher, https://fletcherdigital.com
    * Credit: mjakic https://wordpress.stackexchange.com/questions/178416/how-to-change-the-title-url-on-the-edit-post-screen
    * Credit: Aurovrata Venet https://developer.wordpress.org/reference/hooks/post_row_actions/
    */

    /** Replace hyperlink in post titles on Page, Post, or Template lists with Elementor's editor link */
    add_filter('get_edit_post_link', 'fd_get_edit_post_link', 10, 3 );
    function fd_get_edit_post_link($link, $post_id, $context) {

    // Get current screen parameters
    $scr = get_current_screen();

    // Post Types to Edit with Elementor
    $post_types_for_elementor = array(
    'page',
    'post',
    'elementor_library',
    );

    // When we are on a specified post type screen
    if ( in_array( $scr->post_type, $post_types_for_elementor ) && $context == 'display') {

    // Build the Elementor editor link
    $elementor_editor_link = admin_url( 'post.php?post=' . $post_id . '&action=elementor' );

    return $elementor_editor_link;
    } else {
    return $link;
    }
    }

    /** Add back the default Edit link in Page and Post list rows */
    add_filter( 'page_row_actions', 'fd_add_back_default_edit_link', 10, 2 );
    add_filter( 'post_row_actions', 'fd_add_back_default_edit_link', 10, 2 );
    function fd_add_back_default_edit_link( $actions, $post ) {

    // Build the Elementor edit URL
    $elementor_edit_url = admin_url( 'post.php?post=' . $post->ID . '&action=edit' );

    // Rewrite the normal Edit link
    $actions['edit'] =
    sprintf( '<a href="%1$s">%2$s</a>',
    esc_url( $elementor_edit_url ),
    esc_html( __( 'Default WordPress Editor', 'elementor' ) )
    );

    return $actions;
    }



    /** Repeat above for post_row_actions */


    /** (optional) Remove "Edit with Elementor" link added by Elementor itself */
    add_filter( 'page_row_actions', 'fd_remove_default_edit_with_elementor', 99, 2 );
    add_filter( 'post_row_actions', 'fd_remove_default_edit_with_elementor', 99, 2 );
    function fd_remove_default_edit_with_elementor( $actions, $post ) {

    // Rewrite the normal Edit link
    unset($actions['edit_with_elementor']);

    return $actions;
    }

    /** Alternative: Rewrite just the Edit link, and leave the page title as original */
    /** Rewrite the normal Edit link on lists of Pages and replace it with Elementor's edit link */
    // add_filter( 'page_row_actions', 'fd_elementor_modify_list_row_actions', 10, 2 );
    // add_filter( 'post_row_actions', 'fd_elementor_modify_list_row_actions', 10, 2 );
    // function fd_elementor_modify_list_row_actions( $actions, $post ) {

    // // Build the Elementor edit URL
    // $elementor_edit_url = admin_url( 'post.php?post=' . $post->ID . '&action=elementor' );

    // // Rewrite the normal Edit link
    // $actions['edit'] =
    // sprintf( '<a href="%1$s">%2$s</a>',
    // esc_url( $elementor_edit_url ),
    // esc_html( __( 'Elementor Editor', 'elementor' ) )
    // );

    // return $actions;
    // }