Plugin Directory

Changeset 2480511


Ignore:
Timestamp:
02/24/2021 10:12:48 AM (5 years ago)
Author:
karlogitlea
Message:

Added MyBody

Location:
miqid-elementor/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • miqid-elementor/trunk/core/widget_miqid.php

    r2426420 r2480511  
    44
    55use Elementor\Widget_Base;
    6 use MIQID\Elementor\Handler\{Address, Profile};
     6use MIQID\Elementor\Handler\{Address, MyBody, Profile};
    77use ReflectionClass;
    88
     
    3030
    3131    function getMIQIDFields() {
     32        $options = [];
    3233        $Classes = [
    3334            Profile::class,
    3435            Address::class,
     36            MyBody::class,
    3537        ];
    36         $options = [];
    37         foreach ( $Classes as $i => $Class ) {
    38             if ( ! class_exists( $Class ) ) {
    39                 continue;
    40             }
    4138
    42             $ClassShortName = ( new ReflectionClass( $Class ) )->getShortName();
     39        foreach ( $Classes as $i => $class ) {
     40            $ReflectionClass = new ReflectionClass( $class );
     41            $ShortName       = $ReflectionClass->getShortName();
     42            $class_options   = [];
     43            do {
     44                foreach ( $ReflectionClass->getProperties() as $property ) {
     45                    $class_options[ sprintf( '%s.%s', $ShortName, $property->getName() ) ] = __( $property->getName(), 'miqid-core' );
     46                }
     47            } while ( $ReflectionClass = $ReflectionClass->getParentClass() );
     48
     49            $class_options = array_filter( $class_options, function ( $key ) {
     50                return ! preg_match( '/instance/i', $key );
     51            }, ARRAY_FILTER_USE_KEY );
    4352
    4453            $options[ $i ] = [
    45                 'label'   => __( $ClassShortName, 'miqid-core' ),
    46                 'options' => [],
     54                'label'   => __( $ShortName, 'miqid-core' ),
     55                'options' => $class_options,
    4756            ];
    48 
    49 
    50             $obj      = $Class::Instance();
    51             $obj_data = [];
    52             if ( method_exists( $obj, 'jsonSerialize' ) ) {
    53                 $obj_data = $obj->jsonSerialize();
    54             } else if ( ! empty( get_object_vars( $obj ) ) ) {
    55                 $obj_data = get_object_vars( $obj );
    56             }
    57 
    58             foreach ( $obj_data as $key => $value ) {
    59                 $optionKey                              = sprintf( '%s.%s', $ClassShortName, $key );
    60                 $options[ $i ]['options'][ $optionKey ] = __( $key, 'miqid-core' );
    61             }
    6257        }
    6358
  • miqid-elementor/trunk/miqid-elementor.php

    r2466958 r2480511  
    44 * Plugin Name:       MIQID-Elementor
    55 * Description:       MIQID-Elementor extend Elementor with MIQID data.
    6  * Version:           1.5.2
     6 * Version:           1.6.0
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.2
     
    2424
    2525class Elementor {
    26     const VERSION                   = "1.3";
     26    const VERSION                   = "1.6";
    2727    const MINIMUM_ELEMENTOR_VERSION = "2.0.0";
    2828    const MINIMUM_PHP_VERSION       = "7.2";
  • miqid-elementor/trunk/readme.md

    r2466958 r2480511  
    44Tested up to: 5.6 
    55Requires PHP: 7.2 
    6 Stable tag: 1.5.2 
     6Stable tag: 1.6.0 
    77License: GPL v3 or later 
    88
  • miqid-elementor/trunk/widget/dynamic_images.php

    r2466958 r2480511  
    140140        ];
    141141
    142         $match = apply_filters( sprintf( 'miqid_%s', Util::snake_case( implode( '_', $miqid ) ) ), '' );
     142        $match = do_shortcode( sprintf( '[miqid-%s fields="%s"]', mb_strtolower( array_shift( $miqid ) ), array_shift( $miqid ) ) );
    143143
    144144        $cases = current( array_filter( $cases, function ( $case ) use ( $match ) {
     
    176176    }
    177177
     178    function EscapeNonASCII( $string ) //Convert string to hex, replace non-printable chars with escaped hex
     179    {
     180        $hexbytes = strtoupper( bin2hex( $string ) );
     181        $i        = 0;
     182        while ( $i < strlen( $hexbytes ) ) {
     183            $hexpair = substr( $hexbytes, $i, 2 );
     184            $decimal = hexdec( $hexpair );
     185            if ( $decimal < 32 || $decimal > 126 ) {
     186                $top      = substr( $hexbytes, 0, $i );
     187                $escaped  = EscapeHex( $hexpair );
     188                $bottom   = substr( $hexbytes, $i + 2 );
     189                $hexbytes = $top . $escaped . $bottom;
     190                $i        += 8;
     191            }
     192            $i += 2;
     193        }
     194        $string = hex2bin( $hexbytes );
     195
     196        return $string;
     197    }
     198
     199    function EscapeHex( $string ) //Helper function for EscapeNonASCII()
     200    {
     201        $x            = "5C5C78";                        //\x
     202        $topnibble    = bin2hex( $string[0] );           //Convert top nibble to hex
     203        $bottomnibble = bin2hex( $string[1] );           //Convert bottom nibble to hex
     204        $escaped      = $x . $topnibble . $bottomnibble; //Concatenate escape sequence "\x" with top and bottom nibble
     205
     206        return $escaped;
     207    }
     208
     209    function UnescapeNonASCII( $string ) //Convert string to hex, replace escaped hex with actual hex.
     210    {
     211        $stringtohex = bin2hex( $string );
     212        $stringtohex = preg_replace_callback( '/5c5c78([a-fA-F0-9]{4})/', function ( $m ) {
     213            return hex2bin( $m[1] );
     214        }, $stringtohex );
     215
     216        return hex2bin( strtoupper( $stringtohex ) );
     217    }
    178218}
  • miqid-elementor/trunk/widget/dynamic_text.php

    r2466958 r2480511  
    134134        $icon     = $settings["icon"];
    135135        $cases    = $settings['switch'];
    136         $match    = apply_filters( sprintf( 'miqid_%s', Util::snake_case( implode( '_', $miqid ) ) ), '' );
     136        $match    = do_shortcode( sprintf( '[miqid-%s fields="%s"]', mb_strtolower( array_shift( $miqid ) ), array_shift( $miqid ) ) );
    137137        $cases    = current( array_filter( $cases, function ( $case ) use ( $match ) {
    138138            return preg_match( '/' . $case['match'] . '/i', $match );
  • miqid-elementor/trunk/widget/iconlist.php

    r2466958 r2480511  
    9595            foreach ( $settings['lines'] as $key => $line ) {
    9696                $miqid = explode( '.', $line["miqid"] ?? '' );
    97                 $match = apply_filters( sprintf( 'miqid_%s', Util::snake_case( implode( '_', $miqid ) ) ), '' );
    98 
    99                 $icon = preg_match( '/' . $line['match'] . '/i', $match )
     97                $match = do_shortcode( sprintf( '[miqid-%s fields="%s"]', mb_strtolower( array_shift( $miqid ) ), array_shift( $miqid ) ) );
     98                $icon  = preg_match( '/' . $line['match'] . '/i', $match )
    10099                    ? $line['match_icon']
    101100                    : $line['default_icon'];
  • miqid-elementor/trunk/widget/input.php

    r2466381 r2480511  
    275275        $this->add_render_attribute( 'input', 'type', $type );
    276276        $this->add_render_attribute( 'input', 'name', sprintf( '[%s]', implode( '][', $field ) ) );
    277         $filter = sprintf( 'miqid_%s', Util::snake_case( implode( '_', $field ) ) );
    278         $this->add_render_attribute( 'input', 'value', apply_filters( $filter, '' ) );
     277        $value = do_shortcode( sprintf( '[miqid-%s fields="%s"]', mb_strtolower( array_shift( $miqid ) ), array_shift( $miqid ) ) );
     278        $this->add_render_attribute( 'input', 'value', $value );
    279279
    280280        if ( ! empty( $settings['placeholder'] ) ) {
  • miqid-elementor/trunk/widget/text_hide_if.php

    r2466958 r2480511  
    4747        $text     = $settings['text'];
    4848        $miqid    = explode( '.', $settings["miqid"] ?? '' );
    49         $match    = apply_filters( sprintf( 'miqid_%s', Util::snake_case( implode( '_', $miqid ) ) ), '' );
     49        $match    = do_shortcode( sprintf( '[miqid-%s fields="%s"]', mb_strtolower( array_shift( $miqid ) ), array_shift( $miqid ) ) );
    5050        $negate   = filter_var( $settings['negate'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? false;
    5151
Note: See TracChangeset for help on using the changeset viewer.