• Resolved sabbella

    (@sabbella)


    Hello, I’m using 1.4.3 version of the plugin.

    The problem is that it doesn’t allow me to update or create some snippets. Here is an example:

    <?php {?> 

    <?php

    $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    if (strpos($ref, 'https://mywebsite.es/myweb/') !== FALSE) {

    echo '<a
    title="back"><span style="font-weight: 900;font-size:20px;"><u><strong>Back >></strong></u></span></a>';

    echo "<br>";
    }else{


    }?>



    <div class="mov" style="background-color:#fef6d5;color:#000000;letter-spacing:.1rem;font-size:17px;padding:15px;border:1px solid #dddddd;margin-top:15px!important;">
    <div align="center" style="text-align:center;font-size:20px;"><strong>Ficha</strong></div>
    <div style="padding-top:10px;font-size:17px;">Ficha/strong>.</div>
    </div>
    <br>



    <?php the_field('1field'); ?></br></br>

    <div class="sidebarcustomizada">

    <span style="font-size:20px;"><b>OFERTA DE EMPLEO</b></span>:</br></br>
    <?php the_time('j/n/Y');?></br>
    <?php if ( get_field( '1type' ) ){
    echo "complete</br>";
    } if ( get_field( '2type' ) ){
    echo "partial</br>";
    } ?>

    <?php if ( get_field( 'eso' ) ){
    echo "nothing</br>";
    } else {
    echo "";
    } ?>


    <b>Lugar</b>: <?php the_field('field-1'); ?></br>


    <b>Description</b>: <?php echo wp_kses_post( get_field('field-11') );?> </br>


    </br>
    <b>Name</b>: </br>
    <span style="font-size:16px">After.</span></br>
    </div>
    <?php } ?>

    Could you please tell me how to fix it? I think it is a plugin bug. It doesn’t like “echo” or other things. I am not using cloudfare.

    Thank you,

    Sabbella

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pauserratgutierrez

    (@pauserratgutierrez)

    Hi @sabbella,

    This doesn’t appear to be a bug with the Code Snippets plugin but rather an issue with your custom PHP code. The Code Snippets plugin automatically handles PHP opening and closing tags, so including <?php and ?> in your snippet is unnecessary and can cause issues.

    Here are some suggestions to fix your code:

    1. Remove PHP Tags: Avoid including <?php and ?> in your snippet, as they are already added automatically by the plugin.
    2. Use Correct Syntax: Ensure your PHP code is clean and well-structured
      • Avoid unnecessary braces or misplaced tags.
      • If you’re mixing HTML and PHP, wrap the HTML content inside echo statements to prevent syntax errors.

    For example, instead of: <?php echo "<div>Some Content</div>"; ?>
    Use this directly (without PHP tags in Code Snippets): echo '<div>Some Content</div>';

    If you’re still facing issues, you might want to check for additional errors using WordPress debugging. Add the following to your wp-config.php file:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);

    This will log any issues to wp-content/debug.log for review.

    Hope this helps!
    Pau.

      Thread Starter sabbella

      (@sabbella)

      Thank you Pau!

      Best,

      Sabbella

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