initBaseVariables(); } /** * * @return inspire_Plugin4 */ public function getPlugin() { return $this; } public function loadPluginTextDomain() { load_plugin_textdomain( 'inspire-plugin', FALSE, basename( dirname( __FILE__ ) ) . '/lang/' ); } /** * */ public function initBaseVariables() { $reflection = new ReflectionClass($this); // Set Plugin Path $this->_pluginPath = dirname($reflection->getFileName()); // Set Plugin URL $this->_pluginUrl = plugin_dir_url($reflection->getFileName()); $this->_pluginFilePath = $reflection->getFileName(); $this->_templatePath = '/' . $this->_pluginNamespace . '_templates'; $this->_defaultViewArgs = array( 'pluginUrl' => $this->getPluginUrl() ); register_activation_hook( $this->_pluginFilePath, array( $this, 'activation' ) ); register_deactivation_hook( $this->_pluginFilePath, array( $this, 'deactivation' ) ); register_uninstall_hook( $this->_pluginFilePath, 'inspire_Plugin4::uninstall' ); add_action( 'plugins_loaded', array($this, 'loadPluginTextDomain') ); add_filter( 'plugin_action_links_' . plugin_basename( $this->getPluginFilePath() ), array( $this, 'linksFilter' ) ); /*$this->_initPluginUpdates(); echo '
'; var_dump($this->_pluginPath); var_dump($this->_pluginUrl); var_dump($this->_pluginFilePath); var_dump($this->getTemplatePath()); var_dump($this->getPluginAssetsUrl()); echo '';*/ } /** * Plugin activation hook */ public function activation() { } /** * Plugin deactivation hook */ public function deactivation() { } /** * Plugin uninstall hook */ public static function uninstall() { } /** * * @return string */ public function getPluginUrl() { return esc_url(trailingslashit($this->_pluginUrl)); } public function getPluginAssetsUrl() { return esc_url(trailingslashit($this->getPluginUrl() . 'assets')); } /** * @return string */ public function getTemplatePath() { return trailingslashit($this->_templatePath); } public function getPluginFilePath() { return $this->_pluginFilePath; } public function getNamespace() { return $this->_pluginNamespace; } protected function _initPluginUpdates() { add_filter('pre_set_site_transient_update_plugins', array($this, 'checkForPluginUpdate')); } protected function getPluginUpdateName() { return $this->getNamespace() . '/' . str_replace('woocommerce-', '', $this->getNamespace()) .'.php'; } public function checkForPluginUpdate($checked_data) { global $wp_version; var_dump('y'); if (empty($checked_data->checked)) return $checked_data; var_dump($checked_data); $args = array( 'slug' => $this->getNamespace(), 'version' => $checked_data->checked[$this->getPluginUpdateName()], ); $request_string = array( 'body' => array( 'action' => 'basic_check', 'request' => serialize($args), 'site' => get_bloginfo('url'), 'token' => self::DEFAULT_TOKEN ), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url') ); var_dump($request_string); die(); // Start checking for an update $raw_response = wp_remote_post($this->_wpdeskUpdateUrl, $request_string); if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200)) $response = unserialize($raw_response['body']); if (is_object($response) && !empty($response)) // Feed the update data into WP updater $checked_data->response[$this->getNamespace() .'/'. $this->getNamespace() .'.php'] = $response; return $checked_data; } /** * * @param string $message * @param string $class */ public function addAdminMessage($message, $class = 'updated') { $messages = $this->_getAdminMessages(); if (!is_array($messages)) { $messages = array(); } $messages[$class][] = $message; $this->_setAdminMessages($messages); } protected function _getAdminMessages() { return get_option($this->getNamespace() . '_messages'); } protected function _setAdminMessages($messages) { update_option($this->getNamespace() . '_messages', $messages); } /** * * @param boolean $clean */ public function getAdminMessagesHtml($clean = true) { $messages = $this->_getAdminMessages(); $str = ''; if (is_array($messages) && !empty($messages)) { foreach ($messages as $class => $messagesArray) { $str .= '
' . $message . '
'; } $str .= '' . $message . '
'; } } } if ($clean) { $this->_setFrontMessages(''); } return $str; } /** * Renders end returns selected template * * @param string $name name of the template * @param string $path additional inner path to the template * @param array $args args accesible from template * @return string */ public function loadTemplate($name, $path = '', $args = array()) { //$args = array_merge($this->_defaultViewArgs, array('textDomain', $this->_textDomain), $args); $path = trim($path, '/'); if (file_exists($templateName = implode('/', array(get_template_directory(), $this->getTemplatePath(), $path, $name . '.php')))) { } else { $templateName = implode('/', array($this->_pluginPath, $this->getTemplatePath(), $path, $name . '.php')); } ob_start(); include($templateName); return ob_get_clean(); } /** * Gets setting value * * @param string $name * @param string $default * @return Ambigous