Plugin Directory

Changeset 3399693


Ignore:
Timestamp:
11/20/2025 12:00:15 PM (4 months ago)
Author:
binsaifullah
Message:

version 2.2.0 files are added

Location:
awesome-logo-carousel-block
Files:
69 added
2 edited

Legend:

Unmodified
Added
Removed
  • awesome-logo-carousel-block/trunk/plugin.php

    r3289524 r3399693  
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.0
    8  * Version:           2.1.10
     8 * Version:           2.2.0
    99 * Author:            Gutenbergkits Team
    1010 * Author URI:        https://gutenbergkits.com
    1111 * License:           GPL-2.0-or-later
    12  * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    1312 * Text Domain:       awesome-logo-carousel-blocks
    1413 * Domain Path:       /languages
    15  *
    1614 */
    1715
    18 // Stop Direct Access
    19 if ( ! defined( 'ABSPATH' ) ) {
    20     exit;
    21 }
     16if ( ! defined( 'ABSPATH' ) ) exit;
    2217
    23 
    24 /**
    25  * Blocks Final Class
    26  */
    2718if( ! class_exists ( 'Alcb_Logo_Carousel' ) ) {
    2819
    2920    final class Alcb_Logo_Carousel {
    3021
    31         // version
    32         const VERSION = '2.1.10';
    33        
    34         // instance
     22        const VERSION = '2.2.0';
    3523        private static $instance = null;
    3624
    37         // constructor
    3825        public function __construct() {
     26
     27            // Media Custom Field Hooks
     28            add_filter('attachment_fields_to_edit', [ $this, 'add_custom_link_field_to_media'], 10, 2);
     29            add_filter('attachment_fields_to_save', [ $this, 'save_custom_link_field'], 10, 2);
     30            add_action('rest_api_init', [ $this, 'register_custom_link_rest_field']);
     31
    3932            $this->constants();
    4033            $this->includes();
    4134
    42             // enable redirect
    4335            register_activation_hook( __FILE__, [ $this, 'redirect_to_admin' ] );
    44             // handle redirect
    4536            add_action( 'admin_init', [ $this, 'handle_redirection' ] );
    4637        }
    4738
    48         /**
    49          * Define Constants
    50          *
    51          * @return void
    52          */
    5339        public function constants() {
    5440            $constants = [
     
    6147
    6248            foreach ( $constants as $key => $value ) {
    63                 if ( ! defined( $key ) ) {
    64                     define( $key, $value );
    65                 }
     49                if ( ! defined( $key ) ) define( $key, $value );
    6650            }
    6751        }
    6852
    69         /**
    70          * Includes
    71          *
    72          * @return void
    73          */
    7453        public function includes() {
    7554            require_once ALCB_INC . 'instance.php';
     
    7857        }
    7958
    80         /**
    81          * Instance
    82          *
    83          * @return Alcb_Logo_Carousel
    84          */
    85         public static function instance() {
    86             if ( is_null( self::$instance ) ) {
    87                 self::$instance = new self();
    88             }
    89             return self::$instance;
     59        // Add custom field
     60        public function add_custom_link_field_to_media($form_fields, $post) {
     61            $form_fields['gtvb_custom_link'] = [
     62                'label' => __('Link', 'awesome-logo-carousel-blocks'),
     63                'input' => 'text',
     64                'value' => get_post_meta($post->ID, '_gtvb_custom_link', true),
     65                'helps' => __('Custom link for this image', 'awesome-logo-carousel-blocks')
     66            ];
     67            return $form_fields;
    9068        }
    9169
    92                 /**
    93          * Redirect to admin page after activation
    94          */
     70        // Save custom field
     71        public function save_custom_link_field($post, $attachment) {
     72            if (isset($attachment['gtvb_custom_link'])) {
     73                update_post_meta($post['ID'], '_gtvb_custom_link', sanitize_text_field($attachment['gtvb_custom_link']));
     74            }
     75            return $post;
     76        }
     77
     78        // Add to REST API
     79        public function register_custom_link_rest_field() {
     80            register_rest_field('attachment', 'gtvb_custom_link', [
     81                'get_callback' => function($object){
     82                    return get_post_meta($object['id'], '_gtvb_custom_link', true);
     83                },
     84                'update_callback' => function($value, $object){
     85                    return update_post_meta($object['id'], '_gtvb_custom_link', sanitize_text_field($value));
     86                },
     87                'schema' => [
     88                    'description' => __('Custom link for the image', 'awesome-logo-carousel-blocks'),
     89                    'type' => 'string',
     90                    'context' => ['view', 'edit']
     91                ]
     92            ]);
     93        }
     94
    9595        public function redirect_to_admin() {
    9696            set_transient( '_alcb_redirect', true, 30 );
    9797        }
    9898
    99         /**
    100          * Handle Redirection
    101          */
    10299        public function handle_redirection() {
    103100            if ( get_transient( '_alcb_redirect' ) ) {
    104101                delete_transient( '_alcb_redirect' );
    105                 if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    106                     wp_safe_redirect( admin_url( 'options-general.php?page=aclb-carousel' ) );
    107                     exit;
    108                 }
     102                wp_safe_redirect( admin_url( 'options-general.php?page=aclb-carousel' ) );
     103                exit;
    109104            }
    110105        }
    111106
     107        public static function instance() {
     108            if ( is_null( self::$instance ) ) self::$instance = new self();
     109            return self::$instance;
     110        }
    112111    }
    113112
    114     // initialize the plugin
    115113    function alcb_logo_carousel() {
    116114        return Alcb_Logo_Carousel::instance();
    117115    }
    118116
    119     // kick-off
    120117    alcb_logo_carousel();
    121 
    122118}
  • awesome-logo-carousel-block/trunk/readme.txt

    r3289524 r3399693  
    44Requires at least: 6.0
    55Tested up to: 6.8
    6 Stable tag: 2.1.10
     6Stable tag: 2.2.0
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    8989
    9090== Changelog ==
     91= 2.2.0 =
     92* Fixed: Logo link issues
    9193
    9294= 2.1.10 =
Note: See TracChangeset for help on using the changeset viewer.