| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main builder BSF Updater class. |
| 4 |
* |
| 5 |
* @package cartflows |
| 6 |
*/ |
| 7 |
|
| 8 |
// Prohibit direct script loading. |
| 9 |
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 10 |
if ( ! class_exists( 'Cartflows_Bsf_Updater' ) ) { |
| 11 |
/** |
| 12 |
* Class Cartflows_Bsf_Updater. |
| 13 |
*/ |
| 14 |
class Cartflows_Bsf_Updater { |
| 15 |
|
| 16 |
/** |
| 17 |
* Constructor. |
| 18 |
*/ |
| 19 |
function __construct() { |
| 20 |
|
| 21 |
$this->set_bsf_path(); |
| 22 |
|
| 23 |
add_filter( 'bsf_authors_list', array( $this, 'add_cartflows_author' ) ); |
| 24 |
|
| 25 |
add_action( 'init', array( $this, 'bsf_core_load' ), 999 ); |
| 26 |
add_filter( 'bsf_skip_braisntorm_menu', array( $this, 'skip_brainstorm_menu' ) ); |
| 27 |
add_filter( 'bsf_skip_author_registration', array( $this, 'skip_brainstorm_menu' ) ); |
| 28 |
|
| 29 |
// Disable license activation notice for cartflows. |
| 30 |
add_filter( 'bsf_display_product_activation_notice_cartflows', '__return_false' ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Function Name: add_cartflows_author. |
| 35 |
* Function Description: Adds cartflows author to get updates. |
| 36 |
* |
| 37 |
* @param array $authors authors array. |
| 38 |
*/ |
| 39 |
public function add_cartflows_author( $authors ) { |
| 40 |
|
| 41 |
$authors[] = 'CartFlows Inc'; |
| 42 |
return $authors; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Function Name: set_bsf_path. |
| 47 |
* Function Description: Set path. |
| 48 |
*/ |
| 49 |
public function set_bsf_path() { |
| 50 |
|
| 51 |
$bsf_core_version_file = CARTFLOWS_DIR . 'admin/bsf-core/version.yml'; |
| 52 |
|
| 53 |
if ( is_file( $bsf_core_version_file ) ) { |
| 54 |
global $bsf_core_version, $bsf_core_path; |
| 55 |
$bsf_core_dir = CARTFLOWS_DIR . 'admin/bsf-core/'; |
| 56 |
$version = file_get_contents( $bsf_core_version_file ); |
| 57 |
if ( version_compare( $version, $bsf_core_version, '>' ) ) { |
| 58 |
$bsf_core_version = $version; |
| 59 |
$bsf_core_path = $bsf_core_dir; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Function Name: bsf_core_load. |
| 66 |
* Function Description: Load Core. |
| 67 |
*/ |
| 68 |
public function bsf_core_load() { |
| 69 |
global $bsf_core_version, $bsf_core_path; |
| 70 |
|
| 71 |
if ( is_file( realpath( $bsf_core_path . '/index.php' ) ) ) { |
| 72 |
include_once realpath( $bsf_core_path . '/index.php' ); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Function Name: bsf_get_option. |
| 78 |
* Function Description: Get options. |
| 79 |
* |
| 80 |
* @param Boolean $request true or false. |
| 81 |
*/ |
| 82 |
public function bsf_get_option( $request = false ) { |
| 83 |
$bsf_options = get_option( 'bsf_options' ); |
| 84 |
if ( ! $request ) { |
| 85 |
return $bsf_options; |
| 86 |
} else { |
| 87 |
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Function Name: skip_brainstorm_menu. |
| 93 |
* Function Description: skip_brainstorm_menu. |
| 94 |
* |
| 95 |
* @param string $products products. |
| 96 |
*/ |
| 97 |
public function skip_brainstorm_menu( $products ) { |
| 98 |
|
| 99 |
$product_id = 'cartflows'; |
| 100 |
$products[] = $product_id; |
| 101 |
|
| 102 |
return $products; |
| 103 |
} |
| 104 |
|
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
if ( class_exists( 'Cartflows_Bsf_Updater' ) ) { |
| 109 |
new Cartflows_Bsf_Updater(); |
| 110 |
} |
| 111 |
|