Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter richardlampitt

    (@richardlampitt)

    Ah, for sure, I know it’s a compromise. We don’t have the budget in this project for custom block development, alas.

    The combo of block styles and the drop down is sufficient for getting the gist of the spacing about right within our client’s needs:

    The block styles are just some @media (max-width:47.998rem){} constrained !important overrides. It’s not fully flexible and the UI is a bit inconsistent between the two, but it does that trick. The client will be instructed that the dropdown is a default value, and for smaller viewports the block styles can override that if needed.

    This is the basis for my original query regarding disabling the custom size option – having the dropdown only would ensure the best consistency between the values.

    Thread Starter richardlampitt

    (@richardlampitt)

    @t-p I did have a good mooch around both the user and developer documentation before popping over here. I found everything except this, alas.

    @bcworkz I didn’t want to rely on hiding this part of the UI with CSS in case a user was only presented with the custom height/width interface. The inconsistency would then be rather too incongruous.

    A little further information: We’re relying on the spacer to provide responsive whitespace, using a combination of the height/width input and block styles to select larger-viewport and smaller-viewport values respectively. Our client needs vastly different whitespace for smaller and larger viewports in many cases, that’s currently not possible when applying margin/padding directly to the paragraphs and headings themselves or groups containing them.

    Thread Starter richardlampitt

    (@richardlampitt)

    Perfect, thank you for looking into this!

    It looks like the elementor stores its actual content in the _elementor_data postmeta field. One cannot remove that data without also deleting the content built with Elementor.

    https://bkjproductions.wordpress.com/2018/11/18/elementor-just-what-is-in-that-post_meta-table/

    Here is an additional query that might be useful, as this thread came up whilst I was searching for a similar issue:

    SELECT meta_key, COUNT( meta_key ) 
    FROM wp_postmeta
    GROUP BY meta_key
    ORDER BY COUNT( meta_key ) DESC
    LIMIT 0,500
    ;

    @mariachellini – The plugin now seems to require at least WordPress version 6.5, as it uses the wp_enqueue_script_module() function added in that update.

    Thread Starter richardlampitt

    (@richardlampitt)

    Hello there, Lapzor!

    Thank you very much for the suggestion regarding swapping the theme out – it let us isolate the problem. We have some custom code to handle file uploads through a MC4WP form, that had stopped correctly working.

    Summary – the file upload success check was incorrectly being applied to all forms.

    Code Reference – For reference (and any other users that might find this in future), here is the full code:

    class File_Uploads_Mailchimp extends Child_Theme {

    /**
    * Add file upload support to MC4WP forms
    *
    * @param array $data
    * @param \MC4WP_Form $form
    *
    * @return array
    */

    public function process_form_data($data, MC4WP_Form $form) {
    $file_successfully_processed = false;
    $field_name = "RECEIPT";

    if (
    isset($_FILES[$field_name]) &&
    $_FILES[$field_name]['error'] === UPLOAD_ERR_OK // uploaded okay
    ) {
    // Allowed mime-types and extensions
    $allowed = [
    "jpg" => "image/jpeg",
    "png" => "image/png",
    ];

    // Ensure needed functions exist before attempting to call:
    $wp_admin_includes = ABSPATH . 'wp-admin/includes';
    if ( !function_exists('wp_handle_upload') ) {
    require_once( "{$wp_admin_includes}/file.php" );
    }
    if ( !function_exists('media_handle_upload') ) {
    require_once( "{$wp_admin_includes}/media.php" );
    }
    if ( !function_exists('wp_read_image_metadata') ) {
    require_once( "{$wp_admin_includes}/image.php" );
    }

    $file_type = $_FILES[$field_name]['type']; //returns the mimetype

    if (
    in_array($file_type, $allowed) && // Doubly ensure only images are uploaded
    (int) $_FILES[$field_name]['size'] < 2621440 // 2.5MB in bytes
    ) {
    // Handle file upload:
    add_filter('upload_dir', [ $this, 'alter_upload_directory' ]); // Change the upload directory for this upload only
    $upload = wp_handle_upload($_FILES[$field_name], [
    'test_form' => false,
    'test_file' => false,
    'mimes' => $allowed,
    ]);
    remove_filter('upload_dir', [ $this, 'alter_upload_directory' ]); // Remove the directory change.

    if (
    $upload &&
    !isset($upload['error'])
    ) {
    // Store the file URL in subscriber data:
    $data[$field_name] = $upload['url'];
    $file_successfully_processed = true;
    }
    }
    }

    if (
    /* THIS ISSET() CHECK WAS MISSING, ADDING THIS ISSET() FIXED THE PROBLEM IN THIS THREAD */
    isset($_FILES[$field_name]) &&
    $file_successfully_processed !== true
    ) {
    // empty data to prevent signup, but provide a receipt URL to ensure any later hooks can delete the file
    // uploaded if necessary, such as on a submission error.
    $data = [
    'EMAIL' => '', // prevents a fatal error
    'RECEIPT' => ( isset($data[$field_name]) && $data[$field_name] ) ? $data[$field_name] : '',
    ];
    if (
    isset($upload['file']) &&
    $upload['file'] &&
    file_exists($upload['file']) &&
    is_writeable($upload['file'])
    ) {
    unlink($upload['file']);
    }
    }

    return $data;
    }

    /**
    * Add the required enctype to the form.
    *
    * @param array $attributes
    * @param $form
    */
    function add_form_attributes($attributes, $form) {
    $attributes['enctype'] = "multipart/form-data";
    $attributes['accept'] = "image/png, image/jpeg, image/jpg";
    return $attributes;
    }

    /**
    * Changes the upload directory
    *
    * @param $upload
    *
    * @return mixed
    */
    function alter_upload_directory($upload) {
    $upload['subdir'] = "/_receipt-images{$upload['subdir']}";
    $upload['path'] = "{$upload['basedir']}{$upload['subdir']}";
    $upload['url'] = "{$upload['baseurl']}{$upload['subdir']}";
    return $upload;
    }

    function _var_export_form($form) {
    self::var_export($form);
    }

    public function __construct() {
    parent::__construct();
    $this->add_filters_from_array([
    [ 'mc4wp_form_data', [ $this, 'process_form_data' ], 10, 2 ],
    [ 'mc4wp_form_element_attributes', [ $this, 'add_form_attributes' ], 10, 2 ],
    ]);
    }
    }

    File_Uploads_Mailchimp::get_instance();
    Thread Starter richardlampitt

    (@richardlampitt)

    Hello there, Lapzor!

    The sites are using different custom themes that we developed ourselves. Both are child-themes based on Bootscore.

    We have a staging environment for both sites. I shall give swapping the theme over to TwentyFour a crack, and shall let you know.

    Thread Starter richardlampitt

    (@richardlampitt)

    Hello there, Lapzor!

    Relatedly, we have another client that is using the free version of the plugin that is exhibiting identical behaviour. On https://www.point6.co.uk/view-our-work/ when either scrolling down or clicking on the ‘Sign up to our newsletter >’ link in the footer, the previously functional form is now returning the same ‘Oops. Something went wrong. Please try again later’ error.

    [2024-10-03 09:02:20] ERROR: Form 8304 > Mailchimp API error: 400 Bad Request. Invalid Resource.  The resource submitted could not be validated. - email_address : This value should not be blank.
    Request:
    POST https://us18.api.mailchimp.com/3.0/lists/c2ee4a285e/members
    {"status":"pending","email_address":"","interests":{},"merge_fields":{"FNAME":"Testing","LNAME":"Testerson"},"email_type":"html","ip_signup":"212.82.65.104","tags":[]}
    Response:
    400 Bad Request
    {"type":"https://mailchimp.com/developer/marketing/docs/errors/","title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. For field-specific details, see the 'errors' array.","instance":"0d65f1f8-6cce-c298-353e-77930a891557","errors":[{"field":"email_address","message":"This value should not be blank."}}
    Thread Starter richardlampitt

    (@richardlampitt)

    Hello there, Lapzor!

    We have requested the account details from our client and are waiting for them to get back to us.

    Do you have any further troubleshooting tips or advice we can follow whilst we wait for that information, please?

    Thread Starter richardlampitt

    (@richardlampitt)

    Hello there!

    We have replaced Ditty with a custom solution, as we couldn’t wait any longer for an acknowledgement.

    Best regards

    Thread Starter richardlampitt

    (@richardlampitt)

    Thank you very much, that is exactly what we need!

    Thread Starter richardlampitt

    (@richardlampitt)

    Hi Craig!

    Thanks for the reply. Looking at the alt tags, they have all of the caption apart from the hashtags, unfortunately. Is this something that the plugin could display or is this an instagram limitation?

    Thanks!

    Thread Starter richardlampitt

    (@richardlampitt)

    Hi there! Thanks. How does one update to the latest version of the premium plugin? Will I need to pester my client for their login info for the itthinx site?

    Thread Starter richardlampitt

    (@richardlampitt)

    It breaks the menu on the homepage. I’ve screencapped and highlighted for you:

    https://snag.gy/G0W8a.jpg

    This is how the menu should look, and how it is presently. When the plugin is updated, the menu fails to render.

Viewing 14 replies - 1 through 14 (of 14 total)