#StackBounty: #plugins #php #plugin-development #unit-tests Why is one phpunit test throwing an error on one class when all other class…

Bounty: 50

I’m working on the Liquid Messages plugin. There are some basic PHPUnit tests existing for it and when I run phpunit all pass except for one. It errors out:

There was 1 error:
1) GCS_Async_Test::test_class_access
Exception: Invalid GC_Sermons_Plugin property: async
/long/path/wp-content/plugins/lqd-messages/gc-sermons.php:330
/long/path/wp-content/plugins/lqd-messages/tests/test-async.php:10

The weird thing is that gc-sermons.php contains a number of properties similar to this one. They are initialized like so:

protected $sermons
protected $taxonomies
protected $async

Instances of the classes are attached to the properties:

        public function plugin_classes()
        {
            require_once self::$path . 'functions.php';

            // Attach other plugin classes to the base plugin class.
            $this->sermons = new GCS_Sermons($this);
            $this->taxonomies = new GCS_Taxonomies($this->sermons);
            $this->async = new GCS_Async($this);
            $this->shortcodes = new GCS_Shortcodes($this);
        }

If we look at GCS_Sermons, which is similar to GCS_Async in that it extends another class we see:

class GCS_Sermons extends GCS_Post_Types_Base {

Essentially the same as GCS_Async:

class GCS_Async extends WP_Async_Task {

If we look at the tests we see that the same test is run against GCS_Sermons as GCS_Async, but only fails with GCS_Async:

    function test_class_access() {
        $this->assertTrue( gc_sermons()->sermons instanceof GCS_Sermons );
    }

    function test_class_access() {
        $this->assertTrue( gc_sermons()->async instanceof GCS_Async );
    }

Any ideas why?


Get this bounty!!!

#StackBounty: #plugin-development #javascript #block-editor creating elements/innerblocks via rangecontrol

Bounty: 100

I’m attempting to put together a variable/mixed content carousel block. I’m having issues trying to figure out how to create/delete individual slides in the carousel (using something like rangecontrol).

So far I have this:

const ALLOWED_BLOCKS = [ 'core/paragraph' ];
const BLOCKS_TEMPLATE = [
    [ 'core/columns', {}, [] ],
];

registerBlockType( 'blocks/carousel', {
    title: __( 'Carousel' ),
    icon: 'layout',
    attributes: {
        count: {
            type: 'number',
        },

    },

    edit( { attributes, setAttributes, className } ) {

        const onChangeCount = value => {
            setAttributes( { count: value } );
        };

        return [
            <InspectorControls key="controls">
                <PanelBody>
                    <RangeControl
                        label={ __( 'Slides' ) }
                        value={ attributes.count }
                        onChange={ onChangeCount }
                        min={ 2 }
                        max={ 6 }
                    />
                </PanelBody>
            </InspectorControls>,
            
, ]; }, save( { attributes } ) { return (
); }, } );

So I’m not entirely sure what I need to allow for creating/deleting the slides via the range. If someone could offer me a rough solution and/or point me at some documentation I’d appreciate it.


Get this bounty!!!

#StackBounty: #plugin-development #jquery #block-editor jQuery selectors for editor elements safe to use?

Bounty: 50

Let’s say I want to monitor all the editor blocks. In the standard editor (5.2.2) I can just select the blocks with e.g. $(“div.wp-block”). Will this work across plugins etc or will some plugins alter the editor blocks class/id?

In other words, are there plugins/page builders, etc that alter the DOM structure so that the blocks do not have the “wp-block” class?

I am worried that if the user, for example, uses a plugin that alters how the editor looks/works will break this jQuery select for me?

If using jQuery selectors to get the editor block will not work in some cases, what would be a better approach to do this? I just need to monitor all text users enter in the editor blocks and match to certain keywords.


Get this bounty!!!

#StackBounty: #plugins #plugin-development #svn #wordpress.org WordPress SVN UTF-8 issue

Bounty: 50

I tried to commit the changes to the “Filenames to latin” plugin and got the SVN error.

The error message:

Error: Commit failed (details follow): Error: Commit blocked by
pre-commit hook (exit code 1) with output: Error: [Error output could
not be translated from the native locale to UTF-8.] Error: This error
was generated by a custom hook script on the Subversion server. Error:
Please contact your server administrator for help with resolving this
issue.

The latest code for the plugin I had issues with is in the GIT repo.

Does anyone know how can I solve this issue?

Thank you in advance.


Get this bounty!!!

#StackBounty: #plugin-development #woocommerce #ajax Show special field when correct shipping is chosen

Bounty: 50

I tried this approach:

add_action( 'woocommerce_review_order_before_payment', array( $this, 'my_custom_checkout_field') );
add_action('updated_checkout',array( $this, 'my_custom_checkout_field'));

public function my_custom_checkout_field(){

    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0];
    if($chosen_shipping == 'zasilkovna'){
        include_once('special-field.php');
    }
}

However, the special field does not appear when user clicks the shipping method. User needs to manually refresh the page, which is not good.

I need to hook myself on the ajax and show the field when correct shipping is clicked.

I know the jqery is firing the action, but am not quite sure how to hook on it…


Get this bounty!!!