Plugin Directory

Changeset 3305507


Ignore:
Timestamp:
06/03/2025 07:16:33 AM (10 months ago)
Author:
vaksin
Message:

0.2.6

  • Add auto translation for URL field
  • add radas_config filter hook
Location:
radas
Files:
179 added
5 edited

Legend:

Unmodified
Added
Removed
  • radas/trunk/admin/option-page.php

    r3304643 r3305507  
    2727    protected $fields;
    2828    protected $option_name;
    29     protected $is_wpml_active;
    30     protected $is_breakdance_active;
    3129
    3230    public function __construct(array $page){
    3331        $this->page = $page;
    3432       
    35         $this->is_wpml_active = WPML::is_active();
    36         $this->is_breakdance_active = Breakdance::is_active();
    37 
    3833        if($this->page){
    3934            $this->option_name = $this->page['slug'];
     
    10297        add_shortcode( $this->page['slug'], [$this, 'create_shortcode'] );
    10398
    104         if($this->is_breakdance_active) {
     99        if(Breakdance::is_active()) {
    105100            foreach($this->fields as $field){
    106101                $this->create_bd_dynamic_data($field);
     
    108103        }
    109104
    110         if($this->is_wpml_active) {
     105        if(WPML::is_active()) {
    111106            $this->wpml_setup_string();
    112107        }
     
    114109
    115110    protected function render(){
    116        
    117111        $end_point = RADAS_REST_NAMESPACE . $this->route;
    118112
     
    161155   
    162156    public function rest_permission(\WP_REST_Request $request){
    163        
    164157        // Return false if user does not have capability.
    165158        if ( ! $this->isCapable() ) {
     
    197190        }
    198191
    199         if($this->is_wpml_active) {
     192        if(WPML::is_active()) {
    200193            $this->register_wpml_string();
    201194        }
     
    369362
    370363        $value = $field->get_sanitized_value();
    371 
    372         if( $this->is_wpml_active && !in_array( $field->type, $this->get_wpml_non_translated_field_type() ) ) {
     364       
     365        if( WPML::is_active() && !in_array( $field->type, $this->get_wpml_non_translated_field_type() ) ) {
     366            $translated_value = apply_filters( 'wpml_translate_string', $value , $field->id, $this->get_wpml_package_kind() );     
     367           
     368            if($field->type == 'url' && ($translated_value == $value || $translated_value == 'auto') ){
     369                $translated_value = WPML::get_permalink($value);
     370            }
     371           
     372            $value = $translated_value;           
     373        }   
     374
     375        if( WPML::is_active() && !in_array( $field->type, $this->get_wpml_non_translated_field_type() ) ) {
    373376            $value = apply_filters( 'wpml_translate_string', $value , $field->id, $this->get_wpml_package_kind() );   
    374377        }       
     
    446449        }
    447450       
    448         if ($this->is_wpml_active){
     451        if (WPML::is_active()){
    449452            $package = $this->get_wpml_package_kind();
    450453            do_action( 'wpml_delete_package', $package['name'], $package['kind'] );
  • radas/trunk/inc/functions.php

    r3304643 r3305507  
    22
    33use Radas\Lib\Helper\Breadcrumb;
     4use Radas\Lib\Helper\Breakdance;
    45use Radas\Lib\Helper\Option;
     6use Radas\Lib\Helper\WPML;
    57
    68function radas_get_option(string $slug, string $field_name, array $args = []) {
     
    2426    return Breadcrumb::get_breadcrumb( Breadcrumb::get_radas_breadcrumb_list( $atts['home_text'] ), $atts['separator'] );
    2527});
     28
     29add_action('init', function(){
     30    $config = [];
     31    $config = apply_filters('radas_config', $config);
     32
     33    if(!$config) {
     34        return;
     35    }
     36
     37    if( WPML::is_active() && array_key_exists('translate_menu_url', $config) && $config['translate_menu_url'] ){
     38        add_filter( 'wp_nav_menu_objects', function($items) {
     39            foreach ( $items as $item ) {
     40                $item->url = apply_filters( 'wpml_permalink', $item->url );
     41            }
     42            return $items;
     43        } ); 
     44    }
     45
     46    if( Breakdance::is_active() &&  array_key_exists('do_shortcode_on_bdform', $config) && $config['do_shortcode_on_bdform']){
     47        add_filter('breakdance_render_form_html', function($output){
     48            add_filter("breakdance_singular_content", function ($content) {
     49                return do_shortcode($content);
     50            });
     51            return $output;
     52        });
     53    }
     54});
  • radas/trunk/lib/helper/wpml.php

    r3304101 r3305507  
    2828        }
    2929        return self::$current_language;
    30     }     
     30    }
     31
     32    public static function get_permalink(string $url, string $lang='') {
     33        $lang= $lang ?? self::get_lang();
     34        return  self::is_active() ?  apply_filters( 'wpml_permalink', $url, $lang ) : $url;
     35    }       
    3136}
  • radas/trunk/radas.php

    r3304643 r3305507  
    44 * Plugin URI:        https://wpradas.com
    55 * Description:       The Lightweight WordPress Plugin for Effortless Options Page Creation
    6  * Version:           0.2.5
     6 * Version:           0.2.6
    77 * Requires at least: 6.5
    88 * Requires PHP:      8.0
  • radas/trunk/readme.txt

    r3304643 r3305507  
    55Requires at least: 6.5
    66Tested up to: 6.8.1
    7 Stable tag: 0.2.5
     7Stable tag: 0.2.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7171
    7272== Changelog ==
     73= 0.2.6 =
     74
     75* Add auto translation for URL field
     76* add radas_config filter hook
     77
    7378= 0.2.5 =
    7479
Note: See TracChangeset for help on using the changeset viewer.