Skip to content

Commit

Permalink
Fix register activation hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubboucek committed Oct 14, 2019
1 parent 2e7631c commit 93f2abd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 0 additions & 2 deletions simpleshop-cz.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_' );

Expand Down
12 changes: 9 additions & 3 deletions src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
);
}
Expand Down Expand Up @@ -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' );
}
Expand Down
11 changes: 9 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@ class Plugin {
*/
private $access;

/**
* @var string
*/
private $pluginDirPath;

public function __construct() {
$this->init();
$this->init_i18n();

$this->pluginDirPath = plugin_dir_path( __DIR__ . '/../' );

$this->secure_key = $this->load_api_key();
$this->email = $this->load_email();

add_action( 'tgmpa_register', [ $this, 'register_required_plugins' ] );
register_activation_hook( __FILE__, [ $this, 'ssc_activation_hook' ] );
register_activation_hook( $this->pluginDirPath, [ $this, 'ssc_activation_hook' ] );
}

private function init() {
Expand Down Expand Up @@ -150,7 +157,7 @@ public function init_i18n() {
}

public function load_textdomain_i18n() {
$plugin_rel_path = str_replace( WP_PLUGIN_DIR . '/', '', SIMPLESHOP_PLUGIN_DIR . 'languages/' );
$plugin_rel_path = str_replace( WP_PLUGIN_DIR . '/', '', $this->pluginDirPath . 'languages/' );
load_plugin_textdomain( 'simpleshop-cz', false, $plugin_rel_path );
}
}

0 comments on commit 93f2abd

Please sign in to comment.