Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

How to load Button shortcode dynamic / inline styles from Pricing Tables shortcode?

Open dk-wordpress opened this issue 10 years ago • 7 comments

Hello!

Unyson allows to add any shortcode into Pricing tables in following way (class-fw-option-type-table.php):

'button-row'  => array(
    'button' => ( $button = fw()->extensions->get( 'shortcodes' )->get_shortcode( 'button' ) )
        ? array(
            'type'          => 'popup',
            'popup-title'   => __( 'Button', 'mytheme' ),
            'button'        => __( 'Add', 'mytheme' ),
            'popup-options' => $button->get_options()
        )
        : array()
),

it is so good, and it allows to use all button shortcode options inside Pricing Tables, but it doesn't load dynamic / inline styles for a button automatically.

Is there a way to load inline styles for a button from Pricing table?

When i add "_action_shortcode_button_enqueue_dynamic_css();" function in "static.php" file (in Table extension), i get "function doesn't exist" error, also i tried do_action('fw_ext_shortcodes_enqueue_static:button'); but it falls with erros:

<b>Warning</b>:  Illegal string offset 'atts_string' in <b>\framework-customizations\extensions\shortcodes\shortcodes\button\static.php</b> on line <b>12</b><br />
<br />
<b>Notice</b>:  Uninitialized string offset: 0 in <b>\framework-customizations\extensions\shortcodes\shortcodes\button\static.php</b> on line <b>12</b><br />
<br />
<b>Warning</b>:  Illegal string offset 'post' in <b>\framework-customizations\extensions\shortcodes\shortcodes\button\static.php</b> on line <b>13</b><br />
<br />
<b>Notice</b>:  Uninitialized string offset: 0 in <b>\framework-customizations\extensions\shortcodes\shortcodes\button\static.php</b> on line <b>13</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>\framework-customizations\extensions\shortcodes\shortcodes\button\static.php</b> on line <b>13</b><br />
<br />
<b>Catchable fatal error</b>:  Argument 1 passed to fw_ext_shortcodes_decode_attr() must be of the type array, string given, called in \framework-customizations\extensions\shortcodes\shortcodes\button\static.php on line 13 and defined in <b>\wp-content\plugins\unyson\framework\extensions\shortcodes\helpers.php</b> on line <b>10</b><br />

sorry if this is a noob question, but i can't find any point in documentation regarding this.

So, we have static.php file in Tables shortcode, and is there any way to call "fw_ext_shortcodes_enqueue_static:button" action from Pricing Tables?

Thank you so much!

dk-wordpress avatar Aug 29 '16 08:08 dk-wordpress

I think this code is better

'button-row'  => ( $button = fw_ext( 'shortcodes' )->get_shortcode( 'button' ) )
    ? array(
        'button' =>  array(
            'type' => 'popup',
            'popup-title'   => __( 'Button', 'mytheme' ),
            'button' => __( 'Add', 'wplab-albedo' ),
            'popup-options' => $button->get_options()
        )
    )
    : array(),

So, we have static.php file in Tables shortcode, and is there any way to call "fw_ext_shortcodes_enqueue_static:button" action from Pricing Tables?

Try

if ($button = fw_ext( 'shortcodes' )->get_shortcode( 'button' )) { /** @var FW_Shortcode $button */
    $button->_enqueue_static();
}

ghost avatar Aug 29 '16 11:08 ghost

@moldcraft sorry, but it is still not working. What am i doing wrong? Please see my static.php from table shortcode

<?php if (!defined('FW')) die('Forbidden');

if (!function_exists('_action_mytheme_shortcode_table_enqueue_dynamic_css')):

    /**
     * @internal
     * @param array $data
     */
    function _action_mytheme_shortcode_table_enqueue_dynamic_css( $data ) {

        wp_dequeue_style( 'fw-shortcode-table' );

        wp_enqueue_style(
            'mytheme-tables',
            mytheme_utils::locate_uri( '/css/front/css/shortcodes/table.css' )
        );

        wp_enqueue_style( 'mytheme-table_variable' );

        if ($button = fw_ext( 'shortcodes' )->get_shortcode( 'button' )) { /** @var FW_Shortcode $button */
          $button->_enqueue_static();
        }

    }
    add_action(
      'fw_ext_shortcodes_enqueue_static:table',
      '_action_mytheme_shortcode_table_enqueue_dynamic_css'
    );

endif;

dk-wordpress avatar Aug 29 '16 12:08 dk-wordpress

Can you give admin/ftp access and the steps to reproduce the problem? moldcraft[at]email.com

ghost avatar Aug 29 '16 12:08 ghost

I don't know how to test. Using your code I get errors that I don't have the wplab_albedo_utils class and undefined option type. I commented those lines but I get this

Can you give TeamViewer access?

ghost avatar Aug 29 '16 14:08 ghost

Hi again, @moldcraft!

Please, download this file (stripped version), it works with default "scratch-child" theme, unzip it's content into \wp-content\themes\scratch-child\framework-customizations\extensions\shortcodes\shortcodes\

Please see screenshots attached:

  1. Border radius for button in admin part 2016-08-29_21-53-15

  2. it works fine at front-end 2016-08-29_21-54-19

  3. border radius in Table Button, admin part 2016-08-29_21-54-51

  4. doesn't work at front-ent 2016-08-29_21-55-46

thank you for your patience and for your attention

dk-wordpress avatar Aug 29 '16 18:08 dk-wordpress

Hi, @moldcraft, i see this ticket is closed, but after upgrading Unyson to 2.6.0, this still not working. Could you tell me what should i do to run this?

dk-wordpress avatar Sep 02 '16 09:09 dk-wordpress

These changes will be included in Shortcodes extension v1.3.20

ghost avatar Sep 02 '16 11:09 ghost