: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this->_logger->entrance();
'billing_cycle' => $billing_cycle
$params['trial'] = 'true';
$url = $this->is_addon() ?
$this->_parent->addon_url( $this->_slug ) :
$this->_get_admin_page_url( 'pricing', $params );
return $this->apply_filters( 'pricing_url', $url );
* @author Vova Feldman (@svovaf)
* @param string $billing_cycle Billing cycle
* @param array $extra (optional) Extra parameters, override other query params.
* @param bool|null $network
$billing_cycle = WP_FS__PERIOD_ANNUALLY,
$this->_logger->entrance();
'billing_cycle' => $billing_cycle,
$params['trial'] = 'true';
* Params in extra override other params.
$params = array_merge( $params, $extra );
return $this->apply_filters( 'checkout_url', $this->_get_admin_page_url( 'pricing', $params, $network ) );
* @author Vova Feldman (@svovaf)
* @param number $addon_id
* @param number $pricing_id
* @param string $billing_cycle
* @param bool|null $network
function addon_checkout_url(
$billing_cycle = WP_FS__PERIOD_ANNUALLY,
return $this->checkout_url( $billing_cycle, $is_trial, array(
'plugin_id' => $addon_id,
'pricing_id' => $pricing_id,
#endregion ------------------------------------------------------------------
* Check if plugin has any add-ons.
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3 Base logic only on the parameter provided by the developer in the init function.
$this->_logger->entrance();
return $this->_has_addons;
* Check if plugin can work in anonymous mode.
* @author Vova Feldman (@svovaf)
* @deprecated Please use is_enable_anonymous() instead.
function enable_anonymous() {
return $this->_enable_anonymous;
* Check if plugin can work in anonymous mode.
* @author Vova Feldman (@svovaf)
function is_enable_anonymous() {
return $this->_enable_anonymous;
* Check if plugin is premium only (no free plans).
* @author Vova Feldman (@svovaf)
function is_only_premium() {
return $this->_is_premium_only;
* Checks if the plugin's type is "plugin". The other type is "theme".
* @author Leo Fajardo (@leorw)
return ( WP_FS__MODULE_TYPE_PLUGIN === $this->_module_type );
* @author Leo Fajardo (@leorw)
function get_module_type() {
if ( ! isset( $this->_module_type ) ) {
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
$this->_module_type = $id_slug_type_path_map[ $this->_module_id ]['type'];
return $this->_module_type;
* @author Leo Fajardo (@leorw)
function get_plugin_main_file_path() {
return $this->_plugin_main_file_path;
* Check if module has a premium code version.
* Serviceware module might be freemium without any
* premium code version, where the paid features
* are all part of the service.
* @author Vova Feldman (@svovaf)
function has_premium_version() {
return $this->_has_premium_version;
* Check if feature supported with current site's plan.
* @author Vova Feldman (@svovaf)
* @param number $feature_id
function is_feature_supported( $feature_id ) {
throw new Exception( 'not implemented' );
* @author Vova Feldman (@svovaf)
* @return bool Is running in SSL/HTTPS
* @author Vova Feldman (@svovaf)
* @return bool Is running in AJAX call.
* @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
static function is_ajax() {
return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
* Check if it's an AJAX call targeted for the current module.
* @author Vova Feldman (@svovaf)
* @param array|string $actions Collection of AJAX actions.
function is_ajax_action( $actions ) {
// Verify it's an ajax call.
if ( ! self::is_ajax() ) {
// Verify the call is relevant for the plugin.
if ( $this->_module_id != fs_request_get( 'module_id' ) ) {
// Verify it's one of the specified actions.
if ( is_string( $actions ) ) {
$actions = explode( ',', $actions );
if ( is_array( $actions ) && 0 < count( $actions ) ) {
$ajax_action = fs_request_get( 'action' );
foreach ( $actions as $action ) {
if ( $ajax_action === $this->get_action_tag( $action ) ) {
* Check if it's an AJAX call targeted for current request.
* @author Vova Feldman (@svovaf)
* @param array|string $actions Collection of AJAX actions.
* @param number|null $module_id
static function is_ajax_action_static( $actions, $module_id = null ) {
// Verify it's an ajax call.
if ( ! self::is_ajax() ) {
if ( ! empty( $module_id ) ) {
// Verify the call is relevant for the plugin.
if ( $module_id != fs_request_get( 'module_id' ) ) {
// Verify it's one of the specified actions.
if ( is_string( $actions ) ) {
$actions = explode( ',', $actions );
if ( is_array( $actions ) && 0 < count( $actions ) ) {
$ajax_action = fs_request_get( 'action' );
foreach ( $actions as $action ) {
if ( $ajax_action === self::get_ajax_action_static( $action, $module_id ) ) {
* @author Vova Feldman (@svovaf)
static function is_cron() {
return ( defined( 'DOING_CRON' ) && DOING_CRON );
* @author Leo Fajardo (@leorw)
static function is_admin_post() {
return ( 'admin-post.php' === self::get_current_page() );
* Check if a real user is visiting the admin dashboard.
* @author Vova Feldman (@svovaf)
function is_user_in_admin() {
* Check if a real user is in the customizer view.
* @author Vova Feldman (@svovaf)
static function is_customizer() {
return is_customize_preview();
* Check if running in HTTPS and if site's plan matching the specified plan.
function is_ssl_and_plan( $plan, $exact = false ) {
return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
* Construct plugin's settings page URL.
* @author Vova Feldman (@svovaf)
* @param bool|null $network
function _get_admin_page_url( $page = '', $params = array(), $network = null ) {
if ( is_null( $network ) ) {
$this->_is_network_active &&
( fs_is_network_admin() || ! $this->is_delegated_connection() )
if ( 0 < count( $params ) ) {
foreach ( $params as $k => $v ) {
$params[ $k ] = urlencode( $v );
$page_param = $this->_menu->get_slug( $page );
// Show the opt-in as an overlay for free wp.org themes or themes without any settings page.
$this->show_opt_in_on_themes_page()
$params[ $this->get_unique_affix() . '_show_optin' ] = 'true';
$this->admin_url( 'themes.php', 'admin', $network )
if ( ! $this->has_settings_menu() ) {
if ( ! empty( $page ) ) {
// Module doesn't have a setting page, but since the request is for
// a specific Freemius page, use the admin.php path.
return add_query_arg( array_merge( $params, array(
) ), $this->admin_url( 'admin.php', 'admin', $network ) );
if ( $this->is_activation_mode() ) {
* If plugin doesn't have a settings page, create one for the opt-in screen.
return add_query_arg( array_merge( $params, array(
) ), $this->admin_url( 'admin.php', 'admin', $network ) );
// Plugin without a settings page.
$this->admin_url( 'plugins.php', 'admin', $network )
// Module has a submenu settings page.
if ( ! $this->_menu->is_top_level() ) {
$parent_slug = $this->_menu->get_parent_slug();
$menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
return add_query_arg( array_merge( $params, array(
) ), $this->admin_url( $menu_file, 'admin', $network ) );
// Module has a top level CPT settings page.
if ( $this->_menu->is_cpt() ) {
if ( empty( $page ) && $this->is_activation_mode() ) {
return add_query_arg( array_merge( $params, array(
) ), $this->admin_url( 'admin.php', 'admin', $network ) );
if ( ! empty( $page ) ) {
$params['page'] = $page_param;
$this->admin_url( $this->_menu->get_raw_slug(), 'admin', $network )
// Module has a custom top level settings page.
return add_query_arg( array_merge( $params, array(
) ), $this->admin_url( 'admin.php', 'admin', $network ) );
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
* @author Leo Fajardo (@leorw)
function is_network_active() {
return $this->_is_network_active;
* Delegate activation for the given sites in the network (or all sites if `null`) to site admins.
* @author Leo Fajardo (@leorw)
* @param bool|int[] $all_or_blog_ids