diff --git a/simpleshop-cz.php b/simpleshop-cz.php index 4a8c95a..d20f8a5 100644 --- a/simpleshop-cz.php +++ b/simpleshop-cz.php @@ -21,8 +21,6 @@ require_once __DIR__ . '/vendor/autoload.php'; -define( 'SIMPLESHOP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -define( 'SIMPLESHOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SIMPLESHOP_PLUGIN_VERSION', 'dev-master' ); define( 'SIMPLESHOP_PREFIX', '_ssc_' ); diff --git a/src/Admin.php b/src/Admin.php index d1ce6d5..f1e1cdb 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -16,10 +16,16 @@ class Admin { * @var Plugin */ private $loader; + /** + * @var string + */ + private $pluginDirUrl; public function __construct(Plugin $loader) { $this->loader = $loader; + $this->pluginDirUrl = plugin_dir_url(__DIR__ . '/../'); + add_action( 'admin_menu', [ $this, 'add_settings_page' ] ); add_filter( 'manage_edit-ssc_group_columns', [ $this, 'ssc_group_columns' ] ); add_action( 'manage_ssc_group_posts_custom_column', [ $this, 'ssc_group_column_content' ], 10, 2 ); @@ -122,7 +128,7 @@ public function tiny_mce_new_buttons() { * @return mixed */ public function tiny_mce_add_buttons( $plugins ) { - $plugins['ssctinymceplugin'] = SIMPLESHOP_PLUGIN_URL . 'js/tiny-mce/tiny-mce.js'; + $plugins['ssctinymceplugin'] = $this->pluginDirUrl . 'js/tiny-mce/tiny-mce.js'; return $plugins; } @@ -192,7 +198,7 @@ public function add_settings_page() { 'manage_options', 'simple_shop_settings', [ $this, 'render_settings_page' ], - SIMPLESHOP_PLUGIN_URL . '/img/white_logo.png', + $this->pluginDirUrl . '/img/white_logo.png', 99 ); } @@ -230,7 +236,7 @@ public function ssc_group_column_content( $column, $post_id ) { * Enqueue admin scripts */ public function enqueue_admin_scripts() { - wp_enqueue_style( 'ssc', SIMPLESHOP_PLUGIN_URL . 'css/ssc.css' ); + wp_enqueue_style( 'ssc', $this->pluginDirUrl . 'css/ssc.css' ); wp_register_style( 'jquery-ui', 'https://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' ); wp_enqueue_style( 'jquery-ui' ); } diff --git a/src/Plugin.php b/src/Plugin.php index 3658773..556f191 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -150,7 +150,8 @@ public function init_i18n() { } public function load_textdomain_i18n() { - $plugin_rel_path = str_replace( WP_PLUGIN_DIR . '/', '', SIMPLESHOP_PLUGIN_DIR . 'languages/' ); + $pluginDir = plugin_dir_path( __DIR__ . '/../' ); + $plugin_rel_path = str_replace( WP_PLUGIN_DIR . '/', '', $pluginDir . 'languages/' ); load_plugin_textdomain( 'simpleshop-cz', false, $plugin_rel_path ); } }