Plugin Directory


Ignore:
Timestamp:
02/27/2025 12:14:59 PM (13 months ago)
Author:
EmranAhmed
Message:

Release 1.1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • marquee-block/trunk/includes/Plugin.php

    r3214417 r3247829  
    4848            $this->init();
    4949        } catch ( Exception $e ) {
    50             wp_trigger_error( __METHOD__, $e->getMessage() );
     50            $message = sprintf( '<strong>%s:</strong> %s', $this->name(), $e->getMessage() );
     51            add_action(
     52                'admin_notices',
     53                function () use ( $message ) {
     54                    printf( '<div class="notice notice-error"><p>%s</p></div>', wp_kses_data( $message ) );
     55                },
     56                50
     57            );
    5158        }
    5259
     
    7279
    7380    /**
     81     * Get Plugin Name.
     82     *
     83     * @return string
     84     * @since 1.0.0
     85     */
     86    public function name(): string {
     87        static $names;
     88
     89        if ( is_null( $names ) ) {
     90            $names = get_file_data( $this->get_plugin_file(), array( 'Plugin Name' ) );
     91        }
     92
     93        return esc_attr( $names[0] );
     94    }
     95
     96    /**
    7497     * Get Plugin Version.
    7598     *
     
    124147    public function hooks() {
    125148        // Register with hook.
     149        add_action( 'init', array( $this, 'load_translations' ) );
     150    }
     151
     152    /**
     153     * Load Plugin Translation Files.
     154     *
     155     * @return void
     156     */
     157    public function load_translations() {
     158        load_plugin_textdomain( 'marquee-block', false, $this->plugin_dirname() . '/languages' );
    126159    }
    127160
     
    153186     */
    154187    public function plugin_dirname(): string {
    155         return dirname( plugin_basename( $this->get_plugin_file() ) );
     188        return untrailingslashit( dirname( plugin_basename( $this->get_plugin_file() ) ) );
    156189    }
    157190
Note: See TracChangeset for help on using the changeset viewer.