• Something happened and suddenly I can no longer paste php codes into my functions.php of my wordpress theme.

    I say sudden because I used to add tons of code and now I get critical error every time I try to save a php code. I do not know when or why or how to test where the problem lies.

    What I did so far: Deleted all added php code from functions.php to start blank.
    I did try to change theme (currently am using elementor’s child theme hello).
    Deactivated all plugins.

    WordPress – Version 6.5.4
    Woocommerce – Version 8.8.5

Viewing 2 replies - 1 through 2 (of 2 total)
  • I say sudden because I used to add tons of code and now I get critical error every time I try to save a php code. I do not know when or why or how to test where the problem lies.

    That’s likely because you either have an error in the new code… or where you’re placing the code is introducing the error.

    What I did so far: Deleted all added php code from functions.php to start blank.

    Can you share the full code in the functions.php file that’s throwing the error? Use the Code block, or PasteBin if it’s a lot of code.

    Thread Starter wpidl

    (@wpidl)

    I’m pasting all of it here, but the problem is that it worked before and suddenly it’s all php error, when i try to add new or re-add after I cleaned it all to test.

    // Allow SVG
    add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
    global $wp_version;
    if ( $wp_version !== '4.7.1' ) {
    return $data;
    }
    $filetype = wp_check_filetype( $filename, $mimes );
    return [
    'ext' => $filetype['ext'],
    'type' => $filetype['type'],
    'proper_filename' => $data['proper_filename']
    ];
    }, 10, 4 );

    function cc_mime_types( $mimes ){
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
    }
    add_filter( 'upload_mimes', 'cc_mime_types' );
    function fix_svg() {
    echo '<style type="text/css">
    .attachment-266x266, .thumbnail img {
    width: 100% !important;
    height: auto !important;
    }
    </style>';
    }
    add_action( 'admin_head', 'fix_svg' );

    add_filter( 'pms_member_account_tabs', 'pmsc_change_member_account_tabs', 20, 2 );
    function pmsc_change_member_account_tabs( $tabs, $args ) {
    $tabs['obqvi'] = __( 'Обяви', 'paid-member-subscriptions' );
    $tabs['poruchki'] = __( 'Поръчки', 'paid-member-subscriptions' );
    return $tabs;}

    add_filter( 'pms_account_shortcode_content', 'pmsc_custom_tab_content', 20, 2 );
    function pmsc_custom_tab_content( $output, $active_tab ) {
    if ( $active_tab == 'obqvi' ) {
    $output .= '<h3 class="grids-h">Вашите обяви</h3><a class="grids-a" >Създайте обява</a>';
    $output .= '[wpv-view name="ac-template" ids="6554"]';
    }
    if ( $active_tab == 'poruchki' ) {
    $output .= '<h3 class="grids-h">Вашите поръчки</h3>';
    $output .= '<div class="row-2">
    <div class="column-2">Поръчка №</div>
    <div class="column-2">Дата</div>
    <div class="column-2">Име</div>
    <div class="column-2">Общо в лв.</div>
    </div>';
    $output .= '[wpv-view name="orders" ids="7980"]';
    }
    return $output;}

    /**
    * Filter the upload size limit for non-administrators.
    * @param string $size Upload size limit (in bytes).
    * @return int (maybe) Filtered size limit.
    */
    function filter_site_upload_size_limit( $size ) {
    // Set the upload size limit to 1 MB for users lacking the 'manage_options' capability.
    if ( ! current_user_can( 'manage_options' ) ) {
    // 1 MB.
    $size = 1024 * 5000;
    }
    return $size;
    }add_filter( 'upload_size_limit', 'filter_site_upload_size_limit', 20 );


    //For limiting file type
    add_filter('upload_mimes','restict_mime');

    function restict_mime($mimes) {
    $mimes = array(
    'jpg|jpeg|jpe' => 'image/jpeg',
    'gif' => 'image/gif',
    'png' => 'image/png',
    );
    return $mimes;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.