plugin_dir = trailingslashit( plugin_dir_path( __FILE__ ) ); $this->plugin_url = trailingslashit( plugin_dir_url( __FILE__ ) ); add_action( 'init', array( $this, 'init' ) ); add_action( 'wp_footer', array( $this, 'wp_footer' ), 1000 ); if ( is_admin() ) { include $this->plugin_dir . 'classes/class-addnow-admin-menu.php'; $this->admin_menu = new AddNow_Admin_Menu; add_filter( 'plugin_action_links_'. basename( dirname( __FILE__ ) ) .'/'. basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); } include $this->plugin_dir .'classes/class-addnow-buttons-handler.php'; $this->buttons_handler = new AddNow_Buttons_Handler; include $this->plugin_dir .'classes/class-addnow-shortcode-handler.php'; $this->shortcode_handler = new AddNow_Shortcode_Handler; register_activation_hook( __FILE__, array( $this, 'install' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } /** * * @author Paul Menard * * @since 1.0 * */ function init() { load_plugin_textdomain( 'addnow', false, dirname( plugin_basename( __FILE__ ) ) .'/languages/' ); $this->load_settings(); } /** * * @author Paul Menard * * @since 1.0 * */ function wp_footer() { if ( $this->add_js === true ) { if ( ( isset( $this->settings['widgets'] ) ) && ( ! empty( $this->settings['widgets'] ) ) ) { echo stripslashes( '' ); } } } /** * Add frontend css */ function enqueue_assets() { wp_enqueue_style( 'addnow', plugin_dir_url( __FILE__ ) . '/css/addnow.css' ); } /** * * @author Paul Menard * * @since 1.0 * */ function plugin_action_links( $links ) { $settings_link = '' . __( 'Settings', 'addnow' ) .''; array_unshift( $links, $settings_link ); return $links; } /** * * @author Paul Menard * * @since 1.0 * */ function load_settings() { if ( ! empty( $this->settings ) ) unset( $this->settings ); $this->settings = get_option( $this->settings_key ); $this->convert_settings(); } /** * * @author Paul Menard * * @since 1.0 * */ function update_settings() { $this->settings['version'] = $this->version; delete_option( $this->settings_key ); return update_option( $this->settings_key, $this->settings ); } /** * * @author Paul Menard * * @since 1.0 * */ function get_setting( $key = '', $section = 'settings' ) { if ( isset( $this->settings[ $section ][ $key ] ) ) { if ( is_string( $this->settings[ $section ][ $key ] ) ) { return html_entity_decode( stripslashes( $this->settings[ $section ][ $key ] ) ); } else { return $this->settings[ $section ][ $key ]; } } } /** * * @author Paul Menard * * @since 1.0 * */ function convert_settings() { if ( ! isset( $this->settings['settings'] ) ) $this->settings['settings'] = array(); if ( ! isset( $this->settings['settings']['tracking-code'] ) ) $this->settings['settings']['tracking-code'] = ''; if ( ! isset( $this->settings['widgets'] ) ) $this->settings['widgets'] = array(); } /** * Preprocess widget code before inserting onto a page * @param string $code * @return string */ public static function wrapEmbedCode( $code ) { return '
' . html_entity_decode( stripslashes( $code ) ) . '
'; } /** * * @author Paul Menard * * @since 1.0 * */ function install() { } // End of Functions } $addnow_plugin = new AddNow_Plugin(); }