Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • I’ve got similar issue when going through setup wizard. Checking devtools console, seems there’s a CORS issue:

    
    admin.php:1 Access to fetch at 'https://example.com/cms/wp-admin/
    admin-ajax.php?action=rest-nonce' from origin 'https://www.example.com'
    has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
    header is present on the requested resource. If an opaque response
    serves your needs, set the request's mode to 'no-cors' to fetch the
    resource with CORS disabled.
    
    • This reply was modified 4 years, 8 months ago by lvl99.
    Thread Starter lvl99

    (@lvl99)

    Hi @wfpeter,

    I did as you suggested and troubleshooted with the plugin on and off, refreshing a few times. Still no dice. It is definitely in relation to Wordfence being enabled that the REST API and loopback functionality doesn’t work (in particular, using the wp_remote_post function, from what I can see in the code).

    I’m just disabling Wordfence whenever I need to manually run a background action. I’ve noticed that other background actions like updating the database for Woocommerce are also affected, but I can get around it by using WP CLI and typing wp wc update, even if Wordfence is running.

    Thread Starter lvl99

    (@lvl99)

    Hi @wfpeter

    I went to my host and they said that it wasn’t possible to change the /etc/hosts file. Is there some other option I have available that Wordfence could use?

    Is there any specific reason why it only happens when Wordfence is running?

    Thread Starter lvl99

    (@lvl99)

    Hi @wfpeter, I’ve sent through the diagnostic with my username.

    I don’t have the defined variables as you mentioned. Cloudflare is setup for the website, however it has been already paused as I keep having SSL cipher mismatch issues with it.

    I installed the Site Health plugin and put into troubleshooting mode with a default theme (storefront). I did a test and everything was fine. Then I enabled Wordfence and performed another test and saw that both the REST API and loopback critical errors were visible.

    I’m running PHP 7.4 and WooCommerce 4.6.2 and I still get the issue:

    syntax error, unexpected ':', expecting '{' in plugins/woocommerce/woocommerce.php on line 56

    Thread Starter lvl99

    (@lvl99)

    Hiya Chetna,

    Here’s the full code, in which I have modified only the first line:

    if ( ! file_exists( $wp_load = untrailingslashit( ABSPATH ) . "/wp-load.php" ) ) {
        $wp_load = false;
        $dir     = __FILE__;
        while( '/' != ( $dir = dirname( $dir ) ) ) {
            if( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
                break;
            }
        }
    }
    require_once $wp_load;

    It should check for the ABSPATH location first, and if it returns false, it then checks in other folders.

    With Roots’ Bedrock, they put WP files in a /path/to/website/web/wp/ folder (all other files like uploads, themes and plugins are in the /path/to/website/web/app/ folder), however I’ve modified mine to have WP files in the /path/to/website/web/cms/ folder. Either way, for Root’s Bedrock the ABSPATH points to the folder which contains all the WP CMS files.

    For my server, the wp-load.php file is within the WP CMS folder located at /home/exampleuser/example.com/web/cms/wp-load.php. This means that when your original cron script runs, it can’t find the wp-load.php file because it’s going up from a directory that is separate to the WP CMS files, i.e. /home/exampleuser/example.com/web/app/plugins/woocommerce-abandoned-cart/. The cron script produces errors with a path that specifies /home/wp-load.php.

    @davywavy: If you use SASS/SCSS, LESS or Stylus, then you can apply styles using mixins.

    Since the plugin author has been of no help whatsoever, I’ve looked in the code and discovered that there are some limited WP hooks and CSS classes to customise the contact form’s style and output without needing to edit the plugin’s PHP file. What follows is not an exhaustive list, but it should be enough to get you started.

    Personally, I think Contact Form 7 is much better as it provides more customisation options and AJAX functionality (no page refreshes!). But Jetpack’s contact form is nice for a small version that works OK.

    Hook: grunion_contact_form_success_message
    Changes the success message header after user has successfully submitted message. Usage: takes one HTML string as argument and outputs an HTML string

    These are the CSS classes available I’ve found that you can target:

    form.contact-form
    … is the most generic targeting the form

    form.contact-form > div
    Gets the input field containers

    form.contact-form > div input[type="text"]
    Text input field

    form.contact-form > div input[type="email"]
    Email input field

    form.contact-form > div textarea
    Textarea input field

    form.contact-form > div label.grunion-field-label
    Field labels

    form.contact-form > p.contact-submit
    The area where the submit button goes

    form.contact-form > p.contact-submit input[type="submit"].pushbutton-wide
    The submit button itself

    Success message CSS is pretty general and relies on knowing the contact form’s ID unless you’re happy with targeting a generic blockquote element:

    div#contact-form-{ID} blockquote

    Targeting form error CSS is general too, unless you know the ID of the contact form (targeting is either too general or too generic to be really useful):

    div#contact-form-{ID} div.form-error
    Form error container

    div#contact-form-{ID} div.form-error ul.form-errors > li.form-error-message
    Individual form error messages

    I’ve been working on this as well just recently. Asked (and possibly answered) my own question here: http://wordpress.stackexchange.com/questions/50574/use-have-posts-with-array-of-post-results-retrieved-by-wpdb-get-results

    Thread Starter lvl99

    (@lvl99)

    Ooh, I think I figured it out; I just stumbled upon it now. I’m trying to do some cheeky stuff so it’s pretty minimal at the moment but should serve as a possible foundation:


    function get_posts_custom_query( $query_args ) {
    global $wpdb;

    // Do the necessary funky stuff here to build $sql_query from the given $query_args

    $new_wp_query = new WP_Query();
    $custom_query = $wpdb->get_results($sql_query);

    // Sanitise the each post result
    foreach( $custom_query as $i => $post ) {
    $custom_query[$i] = sanitize_post($post, 'raw');
    }

    // Setup WP_Query object
    $new_wp_query->query = $sql_query
    $new_wp_query->posts = $custom_query;
    $new_wp_query->post_count = count($custom_query);

    // Set the first post
    if ( $new_wp_query->post_count > 0 )
    $new_wp_query->post = $custom_query[0];

    return $new_wp_query;
    }

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