$seconds ) { $status = true; } } else { // If timestamp is not yet set - allow the HTTP request. $status = true; } return $status; } if ( ! function_exists( 'bsf_convert_core_path_to_relative' ) ) { /** * Depracate bsf_convert_core_path_to_relative() to in favour of bsf_core_url() * * @param $path $path deprecated. * @return String URL of bsf-core directory. */ function bsf_convert_core_path_to_relative( $path ) { _deprecated_function( __FUNCTION__, '1.22.46', 'bsf_core_url' ); return bsf_core_url( '' ); } } if ( ! function_exists( 'bsf_core_url' ) ) { /** * BSF Core URL * * @param string $append Append. * @return String URL of bsf-core directory. */ function bsf_core_url( $append = '' ) { $path = wp_normalize_path( BSF_UPDATER_PATH ); $theme_dir = wp_normalize_path( get_template_directory() ); $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); if ( strpos( $path, $theme_dir ) !== false ) { return rtrim( get_template_directory_uri() . '/admin/bsf-core/', '/' ) . $append; } elseif ( strpos( $path, $plugin_dir ) !== false ) { return rtrim( plugin_dir_url( BSF_UPDATER_FILE ), '/' ) . $append; } elseif ( strpos( $path, dirname( plugin_basename( BSF_UPDATER_FILE ) ) ) !== false ) { return rtrim( plugin_dir_url( BSF_UPDATER_FILE ), '/' ) . $append; } return false; } } if ( ! function_exists( 'get_brainstorm_product' ) ) { /** * Get BSF product. * * @param string $product_id Product ID. * @return array Product. */ function get_brainstorm_product( $product_id = '' ) { $all_products = brainstorm_get_all_products(); foreach ( $all_products as $key => $product ) { $product_id_bsf = isset( $product['id'] ) ? ( is_numeric( $product['id'] ) ? (int) $product['id'] : $product['id'] ) : ''; if ( $product_id === $product_id_bsf ) { return $product; } } return array(); } } if ( ! function_exists( 'brainstorm_get_all_products' ) ) { /** * Get BSF all products. * * @param bool $skip_plugins Skip plugins. * @param bool $skip_themes Skip themes. * @param bool $skip_bundled Skip bundled. * * @return array All Products. */ function brainstorm_get_all_products( $skip_plugins = false, $skip_themes = false, $skip_bundled = false ) { $all_products = array(); $brainstrom_products = get_option( 'brainstrom_products', array() ); $brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() ); $brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array(); $brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array(); if ( true === $skip_plugins ) { $all_products = $brainstorm_themes; } elseif ( true === $skip_themes ) { $all_products = $brainstorm_plugins; } else { $all_products = $brainstorm_plugins + $brainstorm_themes; } if ( false === $skip_bundled ) { foreach ( $brainstrom_bundled_products as $parent_id => $parent ) { foreach ( $parent as $key => $product ) { if ( isset( $all_products[ $product->id ] ) ) { $all_products[ $product->id ] = array_merge( $all_products[ $product->id ], (array) $product ); } else { $all_products[ $product->id ] = (array) $product; } } } } return $all_products; } } if ( ! function_exists( 'bsf_extension_nag' ) ) { /** * Generate's markup to generate notice to ask users to install required extensions. * * @since Graupi 1.9 * * @param string $product_id (string) Product ID of the brainstorm product. * @param bool $mu_updater (bool) If True - give nag to separately install brainstorm updater multisite plugin. */ function bsf_extension_nag( $product_id = '', $mu_updater = false ) { $display_nag = get_user_meta( get_current_user_id(), $product_id . '-bsf_nag_dismiss', true ); if ( true === $mu_updater ) { bsf_nag_brainstorm_updater_multisite(); } if ( '1' === $display_nag || ! user_can( get_current_user_id(), 'activate_plugins' ) || ! user_can( get_current_user_id(), 'install_plugins' ) ) { return; } $bsf_installed_plugins = ''; $bsf_not_installed_plugins = ''; $bsf_not_activated_plugins = ''; $installer = ''; $bsf_install = false; $bsf_activate = false; $bsf_bundled_products = bsf_bundled_plugins( $product_id ); $bsf_product_name = brainstrom_product_name( $product_id ); foreach ( $bsf_bundled_products as $key => $plugin ) { if ( ! isset( $plugin->id ) || '' === $plugin->id || ! isset( $plugin->must_have_extension ) || 'false' === $plugin->must_have_extension ) { continue; } $plugin_abs_path = WP_PLUGIN_DIR . '/' . $plugin->init; if ( is_file( $plugin_abs_path ) ) { if ( ! is_plugin_active( $plugin->init ) ) { $bsf_not_activated_plugins .= $bsf_bundled_products[ $key ]->name . ', '; } } else { $bsf_not_installed_plugins .= $bsf_bundled_products[ $key ]->name . ', '; } } $bsf_not_activated_plugins = rtrim( $bsf_not_activated_plugins, ', ' ); $bsf_not_installed_plugins = rtrim( $bsf_not_installed_plugins, ', ' ); if ( '' !== $bsf_not_activated_plugins || '' !== $bsf_not_installed_plugins ) { echo '
'; echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be active : ', 'bsf' ); echo ''; echo esc_html( $bsf_not_activated_plugins ); echo ''; echo '
'; $bsf_activate = true; } if ( '' !== $bsf_not_installed_plugins ) { echo ''; echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be installed and activated : ', 'bsf' ); echo ''; echo esc_html( $bsf_not_installed_plugins ); echo ''; echo '
'; $bsf_install = true; } if ( true === $bsf_activate ) { $installer .= '' . __( 'Begin activating plugins', 'bsf' ) . ' | '; } if ( true === $bsf_install ) { $installer .= '' . __( 'Begin installing plugins', 'bsf' ) . ' | '; } $installer .= '' . __( 'Dismiss This Notice', 'bsf' ) . ''; $installer = ltrim( $installer, '| ' ); wp_nonce_field( 'bsf-extension-nag', 'bsf-extension-nag-nonce', true, 1 ); echo ''; echo esc_html( rtrim( $installer, ' |' ) ); echo '
'; echo ''; /* translators: %1$s: strong tag %2%s: strong tag %3%s: anchor tag %4%s: closing anchor tag */ sprintf( __( 'Looks like you are on a WordPress Multisite, you will need to install and network activate %1$s Brainstorm Updater for Multisite %2$s plugin. Download it from %3$s here %4$s', 'bsf' ), '', '', '', '' ); echo '
'; echo '