Skip to content

Commit

Permalink
v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
algoritmika committed Oct 26, 2024
1 parent d299cfe commit 3b1e748
Show file tree
Hide file tree
Showing 31 changed files with 3,251 additions and 23 deletions.
19 changes: 19 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wpcodefactory/wpfactory-cross-selling"
},
{
"type": "vcs",
"url": "https://github.com/wpcodefactory/wpfactory-admin-menu"
}
],
"require": {
"wpfactory/wpfactory-cross-selling": "*",
"wpfactory/wpfactory-admin-menu": "*"
},
"config": {
"preferred-install": "dist"
}
}
118 changes: 118 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 83 additions & 14 deletions includes/class-alg-wc-po.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Price Offers for WooCommerce - Main Class
*
* @version 3.1.0
* @version 3.3.0
* @since 1.0.0
*
* @author Algoritmika Ltd
Expand Down Expand Up @@ -65,7 +65,7 @@ public static function instance() {
/**
* Alg_WC_PO Constructor.
*
* @version 3.1.0
* @version 3.3.0
* @since 1.0.0
*
* @access public
Expand All @@ -77,6 +77,11 @@ function __construct() {
return;
}

// Load libs
if ( is_admin() ) {
require_once plugin_dir_path( ALG_WC_PO_FILE ) . 'vendor/autoload.php';
}

// Set up localisation
add_action( 'init', array( $this, 'localize' ), 9 );

Expand All @@ -85,7 +90,7 @@ function __construct() {

// Pro
if ( 'price-offerings-for-woocommerce-pro.php' === basename( ALG_WC_PO_FILE ) ) {
$this->pro = require_once( 'pro/class-alg-wc-po-pro.php' );
$this->pro = require_once plugin_dir_path( __FILE__ ) . 'pro/class-alg-wc-po-pro.php';
}

// Include required files
Expand All @@ -105,7 +110,11 @@ function __construct() {
* @since 1.1.0
*/
function localize() {
load_plugin_textdomain( 'price-offerings-for-woocommerce', false, dirname( plugin_basename( ALG_WC_PO_FILE ) ) . '/langs/' );
load_plugin_textdomain(
'price-offerings-for-woocommerce',
false,
dirname( plugin_basename( ALG_WC_PO_FILE ) ) . '/langs/'
);
}

/**
Expand All @@ -118,7 +127,10 @@ function localize() {
*/
function wc_declare_compatibility() {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
$files = ( defined( 'ALG_WC_PO_FILE_FREE' ) ? array( ALG_WC_PO_FILE, ALG_WC_PO_FILE_FREE ) : array( ALG_WC_PO_FILE ) );
$files = ( defined( 'ALG_WC_PO_FILE_FREE' ) ?
array( ALG_WC_PO_FILE, ALG_WC_PO_FILE_FREE ) :
array( ALG_WC_PO_FILE )
);
foreach ( $files as $file ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $file, true );
}
Expand All @@ -128,29 +140,39 @@ function wc_declare_compatibility() {
/**
* includes.
*
* @version 2.0.0
* @version 3.3.0
* @since 1.0.0
*/
function includes() {
// Core
$this->core = require_once( 'class-alg-wc-po-core.php' );
$this->core = require_once plugin_dir_path( __FILE__ ) . 'class-alg-wc-po-core.php';
}

/**
* admin.
*
* @version 2.0.0
* @version 3.3.0
* @since 1.0.0
*/
function admin() {

// Action links
add_filter( 'plugin_action_links_' . plugin_basename( ALG_WC_PO_FILE ), array( $this, 'action_links' ) );

// "Recommendations" page
$this->add_cross_selling_library();

// WC Settings tab as WPFactory submenu item
$this->move_wc_settings_tab_to_wpfactory_menu();

// Settings
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_woocommerce_settings_tab' ) );

// Version update
if ( get_option( 'alg_wc_price_offerings_version', '' ) !== $this->version ) {
add_action( 'admin_init', array( $this, 'version_updated' ) );
}

}

/**
Expand All @@ -164,33 +186,80 @@ function admin() {
*/
function action_links( $links ) {
$custom_links = array();
$custom_links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=alg_wc_price_offerings' ) . '">' . __( 'Settings', 'price-offerings-for-woocommerce' ) . '</a>';
$custom_links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=alg_wc_price_offerings' ) . '">' .
__( 'Settings', 'price-offerings-for-woocommerce' ) .
'</a>';
if ( 'price-offerings-for-woocommerce.php' === basename( ALG_WC_PO_FILE ) ) {
$custom_links[] = '<a target="_blank" style="font-weight: bold; color: green;" href="https://wpfactory.com/item/price-offerings-for-woocommerce/">' .
__( 'Go Pro', 'price-offerings-for-woocommerce' ) . '</a>';
__( 'Go Pro', 'price-offerings-for-woocommerce' ) .
'</a>';
}
return array_merge( $custom_links, $links );
}

/**
* add_cross_selling_library.
*
* @version 3.3.0
* @since 3.3.0
*/
function add_cross_selling_library() {

if ( ! class_exists( '\WPFactory\WPFactory_Cross_Selling\WPFactory_Cross_Selling' ) ) {
return;
}

$cross_selling = new \WPFactory\WPFactory_Cross_Selling\WPFactory_Cross_Selling();
$cross_selling->setup( array( 'plugin_file_path' => ALG_WC_PO_FILE ) );
$cross_selling->init();

}

/**
* move_wc_settings_tab_to_wpfactory_menu.
*
* @version 3.3.0
* @since 3.3.0
*/
function move_wc_settings_tab_to_wpfactory_menu() {

if ( ! class_exists( '\WPFactory\WPFactory_Admin_Menu\WPFactory_Admin_Menu' ) ) {
return;
}

$wpfactory_admin_menu = \WPFactory\WPFactory_Admin_Menu\WPFactory_Admin_Menu::get_instance();

if ( ! method_exists( $wpfactory_admin_menu, 'move_wc_settings_tab_to_wpfactory_menu' ) ) {
return;
}

$wpfactory_admin_menu->move_wc_settings_tab_to_wpfactory_menu( array(
'wc_settings_tab_id' => 'alg_wc_price_offerings',
'menu_title' => __( 'Price Offers', 'price-offerings-for-woocommerce' ),
'page_title' => __( 'Price Offers', 'price-offerings-for-woocommerce' ),
) );

}

/**
* add_woocommerce_settings_tab.
*
* @version 2.0.0
* @version 3.3.0
* @since 1.0.0
*/
function add_woocommerce_settings_tab( $settings ) {
$settings[] = require_once( 'settings/class-alg-wc-po-settings.php' );
$settings[] = require_once plugin_dir_path( __FILE__ ) . 'settings/class-alg-wc-po-settings.php';
return $settings;
}

/**
* version_updated.
*
* @version 2.0.0
* @version 3.3.0
* @since 1.0.0
*/
function version_updated() {
require_once( 'class-alg-wc-po-updates.php' );
require_once plugin_dir_path( __FILE__ ) . 'class-alg-wc-po-updates.php';
do_action( 'alg_wc_price_offerings_before_version_update', $this->version );
update_option( 'alg_wc_price_offerings_version', $this->version );
do_action( 'alg_wc_price_offerings_version_updated', $this->version );
Expand Down
13 changes: 7 additions & 6 deletions langs/price-offerings-for-woocommerce.pot
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,19 @@ msgid_plural "Average offer: %s (from %s offers)"
msgstr[0] ""
msgstr[1] ""

#: includes/class-alg-wc-po.php:167
#: includes/class-alg-wc-po.php:190
msgid "Settings"
msgstr ""

#: includes/class-alg-wc-po.php:170
#: includes/class-alg-wc-po.php:194
msgid "Go Pro"
msgstr ""

#: includes/class-alg-wc-po.php:238 includes/class-alg-wc-po.php:239
#: includes/settings/class-alg-wc-po-settings.php:25
msgid "Price Offers"
msgstr ""

#: includes/classes/class-alg-wc-price-offer.php:185
#, php-format
msgctxt "%s = human-readable time difference"
Expand Down Expand Up @@ -1370,10 +1375,6 @@ msgstr ""
msgid "Footer text color"
msgstr ""

#: includes/settings/class-alg-wc-po-settings.php:25
msgid "Price Offers"
msgstr ""

#: includes/settings/class-alg-wc-po-settings.php:48
msgid "Reset Settings"
msgstr ""
Expand Down
4 changes: 2 additions & 2 deletions price-offerings-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Price Offers for WooCommerce
Plugin URI: https://wpfactory.com/item/price-offerings-for-woocommerce/
Description: Allows your customers to start product price negotiations with you.
Version: 3.2.0
Version: 3.3.0
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: price-offerings-for-woocommerce
Expand Down Expand Up @@ -31,7 +31,7 @@
}
}

defined( 'ALG_WC_PO_VERSION' ) || define( 'ALG_WC_PO_VERSION', '3.2.0' );
defined( 'ALG_WC_PO_VERSION' ) || define( 'ALG_WC_PO_VERSION', '3.3.0' );

defined( 'ALG_WC_PO_FILE' ) || define( 'ALG_WC_PO_FILE', __FILE__ );

Expand Down
Loading

0 comments on commit 3b1e748

Please sign in to comment.