Skip to content

Commit 0045240

Browse files
committed
v3.0.0
1 parent a209cfc commit 0045240

31 files changed

+3307
-68
lines changed

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"repositories": [
3+
{
4+
"type": "vcs",
5+
"url": "https://github.com/wpcodefactory/wpfactory-cross-selling"
6+
},
7+
{
8+
"type": "vcs",
9+
"url": "https://github.com/wpcodefactory/wpfactory-admin-menu"
10+
}
11+
],
12+
"require": {
13+
"wpfactory/wpfactory-cross-selling": "*",
14+
"wpfactory/wpfactory-admin-menu": "*"
15+
},
16+
"config": {
17+
"preferred-install": "dist"
18+
}
19+
}

composer.lock

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-alg-wc-pn.php

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Product Notes for WooCommerce - Main Class
44
*
5-
* @version 2.9.5
5+
* @version 3.0.0
66
* @since 1.0.0
77
*
88
* @author Algoritmika Ltd
@@ -57,7 +57,7 @@ public static function instance() {
5757
/**
5858
* Alg_WC_Product_Notes Constructor.
5959
*
60-
* @version 2.9.2
60+
* @version 3.0.0
6161
* @since 1.0.0
6262
*
6363
* @access public
@@ -69,6 +69,11 @@ function __construct() {
6969
return;
7070
}
7171

72+
// Load libs
73+
if ( is_admin() ) {
74+
require_once plugin_dir_path( ALG_WC_PRODUCT_NOTES_FILE ) . 'vendor/autoload.php';
75+
}
76+
7277
// Set up localisation
7378
add_action( 'init', array( $this, 'localize' ) );
7479

@@ -77,7 +82,7 @@ function __construct() {
7782

7883
// Pro
7984
if ( 'internal-product-notes-for-woocommerce-pro.php' === basename( ALG_WC_PRODUCT_NOTES_FILE ) ) {
80-
require_once( 'pro/class-alg-wc-pn-pro.php' );
85+
require_once plugin_dir_path( __FILE__ ) . 'pro/class-alg-wc-pn-pro.php';
8186
}
8287

8388
// Include required files
@@ -97,7 +102,11 @@ function __construct() {
97102
* @since 2.3.0
98103
*/
99104
function localize() {
100-
load_plugin_textdomain( 'product-notes-for-woocommerce', false, dirname( plugin_basename( ALG_WC_PRODUCT_NOTES_FILE ) ) . '/langs/' );
105+
load_plugin_textdomain(
106+
'product-notes-for-woocommerce',
107+
false,
108+
dirname( plugin_basename( ALG_WC_PRODUCT_NOTES_FILE ) ) . '/langs/'
109+
);
101110
}
102111

103112
/**
@@ -110,7 +119,10 @@ function localize() {
110119
*/
111120
function wc_declare_compatibility() {
112121
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
113-
$files = ( defined( 'ALG_WC_PRODUCT_NOTES_FILE_FREE' ) ? array( ALG_WC_PRODUCT_NOTES_FILE, ALG_WC_PRODUCT_NOTES_FILE_FREE ) : array( ALG_WC_PRODUCT_NOTES_FILE ) );
122+
$files = ( defined( 'ALG_WC_PRODUCT_NOTES_FILE_FREE' ) ?
123+
array( ALG_WC_PRODUCT_NOTES_FILE, ALG_WC_PRODUCT_NOTES_FILE_FREE ) :
124+
array( ALG_WC_PRODUCT_NOTES_FILE )
125+
);
114126
foreach ( $files as $file ) {
115127
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $file, true );
116128
}
@@ -120,57 +132,114 @@ function wc_declare_compatibility() {
120132
/**
121133
* includes.
122134
*
123-
* @version 2.4.0
135+
* @version 3.0.0
124136
* @since 1.0.0
125137
*/
126138
function includes() {
127-
$this->core = require_once( 'class-alg-wc-pn-core.php' );
139+
$this->core = require_once plugin_dir_path( __FILE__ ) . 'class-alg-wc-pn-core.php';
128140
}
129141

130142
/**
131143
* admin.
132144
*
133-
* @version 2.4.0
145+
* @version 3.0.0
134146
* @since 1.0.0
135147
*/
136148
function admin() {
149+
137150
// Action links
138151
add_filter( 'plugin_action_links_' . plugin_basename( ALG_WC_PRODUCT_NOTES_FILE ), array( $this, 'action_links' ) );
152+
153+
// "Recommendations" page
154+
$this->add_cross_selling_library();
155+
156+
// WC Settings tab as WPFactory submenu item
157+
$this->move_wc_settings_tab_to_wpfactory_menu();
158+
139159
// Settings
140160
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_woocommerce_settings_tab' ) );
161+
141162
// Version updated
142163
if ( get_option( 'alg_wc_product_notes_version', '' ) !== $this->version ) {
143164
add_action( 'admin_init', array( $this, 'version_updated' ) );
144165
}
166+
145167
}
146168

147169
/**
148170
* action_links.
149171
*
150-
* @version 2.4.0
172+
* @version 3.0.0
151173
* @since 1.0.0
152174
*
153175
* @param mixed $links
154176
* @return array
155177
*/
156178
function action_links( $links ) {
157179
$custom_links = array();
158-
$custom_links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=alg_wc_product_notes' ) . '">' . __( 'Settings', 'woocommerce' ) . '</a>';
180+
$custom_links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=alg_wc_product_notes' ) . '">' .
181+
__( 'Settings', 'product-notes-for-woocommerce' ) .
182+
'</a>';
159183
if ( 'internal-product-notes-for-woocommerce.php' === basename( ALG_WC_PRODUCT_NOTES_FILE ) ) {
160184
$custom_links[] = '<a target="_blank" style="font-weight: bold; color: green;" href="https://wpfactory.com/item/product-notes-for-woocommerce/">' .
161-
__( 'Go Pro', 'product-notes-for-woocommerce' ) . '</a>';
185+
__( 'Go Pro', 'product-notes-for-woocommerce' ) .
186+
'</a>';
162187
}
163188
return array_merge( $custom_links, $links );
164189
}
165190

191+
/**
192+
* add_cross_selling_library.
193+
*
194+
* @version 3.0.0
195+
* @since 3.0.0
196+
*/
197+
function add_cross_selling_library() {
198+
199+
if ( ! class_exists( '\WPFactory\WPFactory_Cross_Selling\WPFactory_Cross_Selling' ) ) {
200+
return;
201+
}
202+
203+
$cross_selling = new \WPFactory\WPFactory_Cross_Selling\WPFactory_Cross_Selling();
204+
$cross_selling->setup( array( 'plugin_file_path' => ALG_WC_PRODUCT_NOTES_FILE ) );
205+
$cross_selling->init();
206+
207+
}
208+
209+
/**
210+
* move_wc_settings_tab_to_wpfactory_menu.
211+
*
212+
* @version 3.0.0
213+
* @since 3.0.0
214+
*/
215+
function move_wc_settings_tab_to_wpfactory_menu() {
216+
217+
if ( ! class_exists( '\WPFactory\WPFactory_Admin_Menu\WPFactory_Admin_Menu' ) ) {
218+
return;
219+
}
220+
221+
$wpfactory_admin_menu = \WPFactory\WPFactory_Admin_Menu\WPFactory_Admin_Menu::get_instance();
222+
223+
if ( ! method_exists( $wpfactory_admin_menu, 'move_wc_settings_tab_to_wpfactory_menu' ) ) {
224+
return;
225+
}
226+
227+
$wpfactory_admin_menu->move_wc_settings_tab_to_wpfactory_menu( array(
228+
'wc_settings_tab_id' => 'alg_wc_product_notes',
229+
'menu_title' => __( 'Product Notes', 'product-notes-for-woocommerce' ),
230+
'page_title' => __( 'Product Notes', 'product-notes-for-woocommerce' ),
231+
) );
232+
233+
}
234+
166235
/**
167236
* add_woocommerce_settings_tab.
168237
*
169-
* @version 2.4.0
238+
* @version 3.0.0
170239
* @since 1.0.0
171240
*/
172241
function add_woocommerce_settings_tab( $settings ) {
173-
$settings[] = require_once( 'settings/class-alg-wc-pn-settings.php' );
242+
$settings[] = require_once plugin_dir_path( __FILE__ ) . 'settings/class-alg-wc-pn-settings.php';
174243
return $settings;
175244
}
176245

@@ -215,7 +284,10 @@ function plugin_path() {
215284
* @since 2.0.0
216285
*/
217286
function get_id( $private_or_public ) {
218-
return ( 'private' === $private_or_public ? 'alg_wc_internal_product_note' : 'alg_wc_public_product_note' );
287+
return ( 'private' === $private_or_public ?
288+
'alg_wc_internal_product_note' :
289+
'alg_wc_public_product_note'
290+
);
219291
}
220292

221293
}

internal-product-notes-for-woocommerce.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Plugin Name: Product Notes for WooCommerce
44
Plugin URI: https://wpfactory.com/item/product-notes-for-woocommerce/
55
Description: Add notes to WooCommerce products.
6-
Version: 2.9.6
6+
Version: 3.0.0
77
Author: WPFactory
88
Author URI: https://wpfactory.com
99
Text Domain: product-notes-for-woocommerce
1010
Domain Path: /langs
11-
WC tested up to: 9.1
11+
WC tested up to: 9.3
1212
Requires Plugins: woocommerce
1313
*/
1414

@@ -31,7 +31,7 @@
3131
}
3232
}
3333

34-
defined( 'ALG_WC_PRODUCT_NOTES_VERSION' ) || define( 'ALG_WC_PRODUCT_NOTES_VERSION', '2.9.6' );
34+
defined( 'ALG_WC_PRODUCT_NOTES_VERSION' ) || define( 'ALG_WC_PRODUCT_NOTES_VERSION', '3.0.0' );
3535

3636
defined( 'ALG_WC_PRODUCT_NOTES_FILE' ) || define( 'ALG_WC_PRODUCT_NOTES_FILE', __FILE__ );
3737

0 commit comments

Comments
 (0)