Support » Plugin: Gutenberg » Error message when adding alignwide for full width

  • Resolved MemeRunner

    (@memerunner)



    I’m trying to add alignwide capabilities according to the directions here.
    https://richtabor.com/gutenberg-image-alignments/

    I’ve added the following code after localization is set:
    `function genesis_sample_localization_setup() {
    add_theme_support( ‘align-wide’ );
    }
    add_action( ‘after_setup_theme’, ‘genesis_sample_localization_setup’)

    However, I’m getting the following Error message:
    “Your PHP code changes were rolled back due to an error on line 35 of file wp-content/themes/genesis-sample-1/functions.php. Please fix and try saving again.

    Cannot redeclare genesis_sample_localization_setup() (previously declared in wp-content/themes/genesis-sample-1/functions.php:28)”

    I’m assuming I don’t have the right parameter name where I’m entering “genesis_sample_localization_setup”, but can’t find anything else likely in my functions.php file.

    Any help on this greatly appreciated.
    thx
    doug

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Marius L. J.

    (@clorith)

    Hiya,

    This indicates that the function name has been used before, try something like this instead:

    
    function wp4327894732890_align_wide() {
        add_theme_support( ‘align-wide’ );
    }
    add_action( ‘after_setup_theme’, ‘wp4327894732890_align_wide’ )
    
    MemeRunner

    (@memerunner)

    Thanks, Marius. Appreciate your input.

    So it sounds like the function name “wp4327894732890_align_wide” is arbitrary, and just needs to match the parameter in the add_action function?

    I tried using the following code:

    // Add 'alignfull'
    
    function arrovox_align_wide() {
    add_theme_support( ‘align-wide’ );
    }
    add_action( ‘after_setup_theme’, ‘arrovox_align_wide’)

    However, when I tried to update the functions.php file, I received the following error message:

    Your PHP code changes were rolled back due to an error on line 41 of file wp-content/themes/genesis-sample-1/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘require_once’ (T_REQUIRE_ONCE)

    This is the code on line 41.
    require_once get_stylesheet_directory() . '/lib/helper-functions.php';

    When I remove all the Alignfull code references from above, I can update the functions.php file fine.

    Any idea what’s going on?
    thanks
    doug

    • This reply was modified 1 month ago by  MemeRunner.
    Moderator Marius L. J.

    (@clorith)

    Hi,

    I see that some fancy quotes are being added somehow, try typing it manually, instead of copy-pasting, and see if it works better for you then 🙂

    MemeRunner

    (@memerunner)

    Thanks, Marius, but typed it in by hand, and still getting the same error message:

    Your PHP code changes were rolled back due to an error on line 39 of file wp-content/themes/genesis-sample-1/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘require_once’ (T_REQUIRE_ONCE)

    Line 39 of functions.php is:
    require_once get_stylesheet_directory() . '/lib/helper-functions.php';

    When you mention you’re seeing additional quotes, I’m not seeing any difference between what you wrote and my version. Can you tell me what quotes you’re referring to?

    thanks
    doug

    Moderator Marius L. J.

    (@clorith)

    I’ve typed it out anew, let’s see if this one works better 🙂

    
    function wp4327894732890_align_wide() {
        add_theme_support( 'align-wide' );
    }
    add_action( 'after_setup_theme', 'wp4327894732890_align_wide' );
    

    Apologies for the extra work, obviously not our intention 🙂

    MemeRunner

    (@memerunner)

    Thanks, Marius. Appreciate you clarifying that. And functions.php accepted it, so that was it!

    I’ve added the CSS for .alignfull and .alignwide, and then entered the alignfull CLASS into the block additional CSS field. However the image is only extends to the left edge. It just repositioned the image to the left edge.
    http://eme.88b.myftpupload.com/

    I’m sure it’s something about my .alignfull CSS calc, below, as I’m playing around with the values and getting various results, but haven’t been able to get the image to extend to both the left and right edges.

    Can you tell what the problem might be?

    .entry-content .alignfull {
        margin-left  : calc( -100vw / 2 + 100% / 2 );
        margin-right : calc( -100vw / 2 + 100% / 2 );
        max-width    : 100vw;
    }
    
    .entry-content .alignwide {
        margin-left  : -100px;
        margin-right : -100px;
        max-width    : 1024px;
    }
    Moderator Marius L. J.

    (@clorith)

    Your .alignfull needs a width declaration as well, try a width: auto;.

    MemeRunner

    (@memerunner)

    That was it. Fantastic. Thanks, Marius!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.