PATH:
home
/
letacommog
/
camarsac
/
wp-content
/
plugins
/
jet-engine
/
includes
/
modules
/
qr-code
<?php /** * QR Code embed module */ // If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { die; } if ( ! class_exists( 'Jet_Engine_Module_QR_Code' ) ) { /** * Define Jet_Engine_Module_QR_Code class */ class Jet_Engine_Module_QR_Code extends Jet_Engine_Module_Base { private $qr_code_api = 'https://api.qrserver.com/v1/create-qr-code/'; /** * Module ID * * @return string */ public function module_id() { return 'qr-code'; } /** * Module name * * @return string */ public function module_name() { return __( 'QR Code for Dynamic Field widget', 'jet-engine' ); } /** * Returns detailed information about current module for the dashboard page * @return [type] [description] */ public function get_module_details() { return '<p>After activation, in the Meta Field drop-down menu of the Content settings tab of the Dynamic Field widget in Elementor page builder appears a “QR Code” option.</p> <p>This option allows you to choose any text data placed to the meta field and display it as a QR code.</p>'; } public function get_video_embed() { return 'https://www.youtube.com/embed/uz5bJ8D36BQ'; } /** * Returns array links to the module-related resources * @return array */ public function get_module_links() { return array( array( 'label' => 'JetEngine: How to Enable Extra Modules to Work with a Dynamic Calendar, QR Codes, and Galleries', 'url' => 'https://crocoblock.com/knowledge-base/articles/jetengine-how-to-enable-extra-modules-to-work-with-a-dynamic-calendar-qr-codes-and-galleries/', ), array( 'label' => 'How to display QR codes with the Dynamic Field widget', 'url' => 'https://www.youtube.com/watch?v=uz5bJ8D36BQ', 'is_video' => true, ), ); } /** * Module init * * @return void */ public function module_init() { add_filter( 'jet-engine/listings/allowed-callbacks', array( $this, 'add_qr_code_cb' ) ); add_filter( 'jet-engine/listing/dynamic-field/callback-args', array( $this, 'cb_args' ), 10, 4 ); add_action( 'jet-engine/listing/dynamic-field/callback-controls', array( $this, 'cb_controls' ) ); } /** * Add grid gallery to callbacks * * @param array $callbacks [description] */ public function add_qr_code_cb( $callbacks = array() ) { $callbacks['jet_engine_get_qr_code'] = __( 'QR Code', 'jet-engine' ); return $callbacks; } /** * Add call-back related controls * * @param [type] $widget [description] * @return [type] [description] */ public function cb_controls( $widget ) { $widget->add_control( 'qr_code_size', array( 'label' => esc_html__( 'QR Code Size', 'jet-engine' ), 'type' => Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 50, 'max' => 400, ), ), 'condition' => array( 'dynamic_field_filter' => 'yes', 'filter_callback' => array( 'jet_engine_get_qr_code' ), ), ) ); } /** * Callback arguments * * @param [type] $args [description] * @param [type] $callback [description] * @param [type] $settings [description] * @param [type] $widget [description] * @return [type] [description] */ public function cb_args( $args, $callback, $settings, $widget ) { if ( 'jet_engine_get_qr_code' !== $callback ) { return $args; } $size = ! empty( $settings['qr_code_size'] ) ? absint( $settings['qr_code_size']['size'] ) : 150; return array_merge( $args, array( $size ) ); } /** * Get QR Code for meta key * * @param [type] $meta_value [description] * @param integer $size [description] * @return [type] [description] */ public function get_qr_code( $value = null, $size = 150 ) { $hash = 'qr_' . substr( base64_encode( $size . $value ), 0, 30 ); $cached = get_transient( $hash ); if ( $cached ) { return $cached; } $request = add_query_arg( array( 'size' => $size . 'x' . $size, 'data' => $value, 'format' => 'svg', ), $this->qr_code_api ); $response = wp_remote_get( $request ); $svg = wp_remote_retrieve_body( $response ); set_transient( $hash, $svg, DAY_IN_SECONDS ); return $svg; } } }
[+]
..
[-] qr-code.php
[edit]