repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Freemius/wordpress-sdk
includes/entities/class-fs-plugin-license.php
FS_Plugin_License.can_activate_bulk
function can_activate_bulk( $production_count, $localhost_count ) { if ( $this->is_unlimited() ) { return true; } /** * For simplicity, the logic will work as following: when given X sites to activate the license on, if it's * possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them, * do NOT activate on any of them. */ return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) ); }
php
function can_activate_bulk( $production_count, $localhost_count ) { if ( $this->is_unlimited() ) { return true; } /** * For simplicity, the logic will work as following: when given X sites to activate the license on, if it's * possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them, * do NOT activate on any of them. */ return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) ); }
[ "function", "can_activate_bulk", "(", "$", "production_count", ",", "$", "localhost_count", ")", "{", "if", "(", "$", "this", "->", "is_unlimited", "(", ")", ")", "{", "return", "true", ";", "}", "/**\n * For simplicity, the logic will work as following: w...
Check if license can be activated on a given number of production and localhost sites. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $production_count @param int $localhost_count @return bool
[ "Check", "if", "license", "can", "be", "activated", "on", "a", "given", "number", "of", "production", "and", "localhost", "sites", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/entities/class-fs-plugin-license.php#L211-L222
train
Freemius/wordpress-sdk
includes/entities/class-fs-plugin-plan.php
FS_Plugin_Plan.has_technical_support
function has_technical_support() { return ( ! empty( $this->support_email ) || ! empty( $this->support_skype ) || ! empty( $this->support_phone ) || ! empty( $this->is_success_manager ) ); }
php
function has_technical_support() { return ( ! empty( $this->support_email ) || ! empty( $this->support_skype ) || ! empty( $this->support_phone ) || ! empty( $this->is_success_manager ) ); }
[ "function", "has_technical_support", "(", ")", "{", "return", "(", "!", "empty", "(", "$", "this", "->", "support_email", ")", "||", "!", "empty", "(", "$", "this", "->", "support_skype", ")", "||", "!", "empty", "(", "$", "this", "->", "support_phone", ...
Checks if this plan supports "Technical Support". @author Leo Fajardo (leorw) @since 1.2.0 @return bool
[ "Checks", "if", "this", "plan", "supports", "Technical", "Support", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/entities/class-fs-plugin-plan.php#L127-L133
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.get_original_menu_slug
function get_original_menu_slug() { if ( 'cpt' === $this->_type ) { return add_query_arg( array( 'post_type' => $this->_menu_slug ), 'edit.php' ); } if ( false === strpos( $this->_menu_slug, '.php?' ) ) { return $this->_menu_slug; } else { return $this->_module_unique_affix; } }
php
function get_original_menu_slug() { if ( 'cpt' === $this->_type ) { return add_query_arg( array( 'post_type' => $this->_menu_slug ), 'edit.php' ); } if ( false === strpos( $this->_menu_slug, '.php?' ) ) { return $this->_menu_slug; } else { return $this->_module_unique_affix; } }
[ "function", "get_original_menu_slug", "(", ")", "{", "if", "(", "'cpt'", "===", "$", "this", "->", "_type", ")", "{", "return", "add_query_arg", "(", "array", "(", "'post_type'", "=>", "$", "this", "->", "_menu_slug", ")", ",", "'edit.php'", ")", ";", "}...
Get plugin's original menu slug. @author Vova Feldman (@svovaf) @since 1.1.3 @return string
[ "Get", "plugin", "s", "original", "menu", "slug", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L396-L408
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.is_main_settings_page
function is_main_settings_page() { if ( $this->_menu_exists && ( fs_is_plugin_page( $this->_menu_slug ) || fs_is_plugin_page( $this->_module_unique_affix ) ) ) { /** * Module has a settings menu and the context page is the main settings page, so assume it's in * activation (doesn't really check if already opted-in/skipped or not). * * @since 1.2.2 */ return true; } global $pagenow; if ( ( WP_FS__MODULE_TYPE_THEME === $this->_module_type ) && Freemius::is_themes_page() ) { /** * In activation only when show_optin query string param is given. * * @since 1.2.2 */ return fs_request_get_bool( $this->_module_unique_affix . '_show_optin' ); } return false; }
php
function is_main_settings_page() { if ( $this->_menu_exists && ( fs_is_plugin_page( $this->_menu_slug ) || fs_is_plugin_page( $this->_module_unique_affix ) ) ) { /** * Module has a settings menu and the context page is the main settings page, so assume it's in * activation (doesn't really check if already opted-in/skipped or not). * * @since 1.2.2 */ return true; } global $pagenow; if ( ( WP_FS__MODULE_TYPE_THEME === $this->_module_type ) && Freemius::is_themes_page() ) { /** * In activation only when show_optin query string param is given. * * @since 1.2.2 */ return fs_request_get_bool( $this->_module_unique_affix . '_show_optin' ); } return false; }
[ "function", "is_main_settings_page", "(", ")", "{", "if", "(", "$", "this", "->", "_menu_exists", "&&", "(", "fs_is_plugin_page", "(", "$", "this", "->", "_menu_slug", ")", "||", "fs_is_plugin_page", "(", "$", "this", "->", "_module_unique_affix", ")", ")", ...
Is user on plugin's admin activation page. @author Vova Feldman (@svovaf) @since 1.0.8 @return bool
[ "Is", "user", "on", "plugin", "s", "admin", "activation", "page", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L430-L454
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.override_submenu_action
function override_submenu_action( $parent_slug, $menu_slug, $function ) { global $submenu; $menu_slug = plugin_basename( $menu_slug ); $parent_slug = plugin_basename( $parent_slug ); if ( ! isset( $submenu[ $parent_slug ] ) ) { // Parent menu not exist. return false; } $found_submenu_item = false; foreach ( $submenu[ $parent_slug ] as $submenu_item ) { if ( $menu_slug === $submenu_item[2] ) { $found_submenu_item = $submenu_item; break; } } if ( false === $found_submenu_item ) { // Submenu item not found. return false; } // Remove current function. $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); remove_all_actions( $hookname ); // Attach new action. add_action( $hookname, $function ); return $hookname; }
php
function override_submenu_action( $parent_slug, $menu_slug, $function ) { global $submenu; $menu_slug = plugin_basename( $menu_slug ); $parent_slug = plugin_basename( $parent_slug ); if ( ! isset( $submenu[ $parent_slug ] ) ) { // Parent menu not exist. return false; } $found_submenu_item = false; foreach ( $submenu[ $parent_slug ] as $submenu_item ) { if ( $menu_slug === $submenu_item[2] ) { $found_submenu_item = $submenu_item; break; } } if ( false === $found_submenu_item ) { // Submenu item not found. return false; } // Remove current function. $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); remove_all_actions( $hookname ); // Attach new action. add_action( $hookname, $function ); return $hookname; }
[ "function", "override_submenu_action", "(", "$", "parent_slug", ",", "$", "menu_slug", ",", "$", "function", ")", "{", "global", "$", "submenu", ";", "$", "menu_slug", "=", "plugin_basename", "(", "$", "menu_slug", ")", ";", "$", "parent_slug", "=", "plugin_...
Override submenu's action. @author Vova Feldman (@svovaf) @since 1.1.0 @param string $parent_slug @param string $menu_slug @param callable $function @return false|string If submenu exist, will return the hook name.
[ "Override", "submenu", "s", "action", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L470-L502
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.find_top_level_menu
private function find_top_level_menu() { global $menu; $position = - 1; $found_menu = false; $menu_slug = $this->get_raw_slug(); $hook_name = get_plugin_page_hookname( $menu_slug, '' ); foreach ( $menu as $pos => $m ) { if ( $menu_slug === $m[2] ) { $position = $pos; $found_menu = $m; break; } } if ( false === $found_menu ) { return false; } return array( 'menu' => $found_menu, 'position' => $position, 'hook_name' => $hook_name ); }
php
private function find_top_level_menu() { global $menu; $position = - 1; $found_menu = false; $menu_slug = $this->get_raw_slug(); $hook_name = get_plugin_page_hookname( $menu_slug, '' ); foreach ( $menu as $pos => $m ) { if ( $menu_slug === $m[2] ) { $position = $pos; $found_menu = $m; break; } } if ( false === $found_menu ) { return false; } return array( 'menu' => $found_menu, 'position' => $position, 'hook_name' => $hook_name ); }
[ "private", "function", "find_top_level_menu", "(", ")", "{", "global", "$", "menu", ";", "$", "position", "=", "-", "1", ";", "$", "found_menu", "=", "false", ";", "$", "menu_slug", "=", "$", "this", "->", "get_raw_slug", "(", ")", ";", "$", "hook_name...
Find plugin's admin dashboard main menu item. @author Vova Feldman (@svovaf) @since 1.0.2 @return string[]|false
[ "Find", "plugin", "s", "admin", "dashboard", "main", "menu", "item", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L516-L542
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.find_main_submenu
private function find_main_submenu() { global $submenu; $top_level_menu_slug = $this->get_top_level_menu_slug(); if ( ! isset( $submenu[ $top_level_menu_slug ] ) ) { return false; } $submenu_slug = $this->get_raw_slug(); $position = - 1; $found_submenu = false; $hook_name = get_plugin_page_hookname( $submenu_slug, '' ); foreach ( $submenu[ $top_level_menu_slug ] as $pos => $sub ) { if ( $submenu_slug === $sub[2] ) { $position = $pos; $found_submenu = $sub; } } if ( false === $found_submenu ) { return false; } return array( 'menu' => $found_submenu, 'parent_slug' => $top_level_menu_slug, 'position' => $position, 'hook_name' => $hook_name ); }
php
private function find_main_submenu() { global $submenu; $top_level_menu_slug = $this->get_top_level_menu_slug(); if ( ! isset( $submenu[ $top_level_menu_slug ] ) ) { return false; } $submenu_slug = $this->get_raw_slug(); $position = - 1; $found_submenu = false; $hook_name = get_plugin_page_hookname( $submenu_slug, '' ); foreach ( $submenu[ $top_level_menu_slug ] as $pos => $sub ) { if ( $submenu_slug === $sub[2] ) { $position = $pos; $found_submenu = $sub; } } if ( false === $found_submenu ) { return false; } return array( 'menu' => $found_submenu, 'parent_slug' => $top_level_menu_slug, 'position' => $position, 'hook_name' => $hook_name ); }
[ "private", "function", "find_main_submenu", "(", ")", "{", "global", "$", "submenu", ";", "$", "top_level_menu_slug", "=", "$", "this", "->", "get_top_level_menu_slug", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "submenu", "[", "$", "top_level_menu_sl...
Find plugin's admin dashboard main submenu item. @author Vova Feldman (@svovaf) @since 1.2.1.6 @return array|false
[ "Find", "plugin", "s", "admin", "dashboard", "main", "submenu", "item", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L552-L585
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.remove_all_submenu_items
private function remove_all_submenu_items() { global $submenu; $menu_slug = $this->get_raw_slug(); if ( ! isset( $submenu[ $menu_slug ] ) ) { return false; } /** * This method is NOT executed for WordPress.org themes. * Since we maintain only one version of the SDK we added this small * hack to avoid the error from Theme Check since it's a false-positive. * * @author Vova Feldman (@svovaf) * @since 1.2.2.7 */ $submenu_ref = &$submenu; $submenu_ref[ $menu_slug ] = array(); return true; }
php
private function remove_all_submenu_items() { global $submenu; $menu_slug = $this->get_raw_slug(); if ( ! isset( $submenu[ $menu_slug ] ) ) { return false; } /** * This method is NOT executed for WordPress.org themes. * Since we maintain only one version of the SDK we added this small * hack to avoid the error from Theme Check since it's a false-positive. * * @author Vova Feldman (@svovaf) * @since 1.2.2.7 */ $submenu_ref = &$submenu; $submenu_ref[ $menu_slug ] = array(); return true; }
[ "private", "function", "remove_all_submenu_items", "(", ")", "{", "global", "$", "submenu", ";", "$", "menu_slug", "=", "$", "this", "->", "get_raw_slug", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "submenu", "[", "$", "menu_slug", "]", ")", ")"...
Remove all sub-menu items. @author Vova Feldman (@svovaf) @since 1.0.7 @return bool If submenu with plugin's menu slug was found.
[ "Remove", "all", "sub", "-", "menu", "items", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L595-L616
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.main_menu_url
function main_menu_url() { $this->_logger->entrance(); if ( $this->_is_top_level ) { $menu = $this->find_top_level_menu(); } else { $menu = $this->find_main_submenu(); } $parent_slug = isset( $menu['parent_slug'] ) ? $menu['parent_slug'] : 'admin.php'; return admin_url( $parent_slug . '?page=' . $menu['menu'][2] ); }
php
function main_menu_url() { $this->_logger->entrance(); if ( $this->_is_top_level ) { $menu = $this->find_top_level_menu(); } else { $menu = $this->find_main_submenu(); } $parent_slug = isset( $menu['parent_slug'] ) ? $menu['parent_slug'] : 'admin.php'; return admin_url( $parent_slug . '?page=' . $menu['menu'][2] ); }
[ "function", "main_menu_url", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "_is_top_level", ")", "{", "$", "menu", "=", "$", "this", "->", "find_top_level_menu", "(", ")", ";", "}", "else"...
Get module's main admin setting page URL. @todo This method was only tested for wp.org compliant themes with a submenu item. Need to test for plugins with top level, submenu, and CPT top level, menu items. @author Vova Feldman (@svovaf) @since 1.2.2.7 @return string
[ "Get", "module", "s", "main", "admin", "setting", "page", "URL", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L661-L675
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.add_counter_to_menu_item
function add_counter_to_menu_item( $counter = 1, $class = '' ) { global $menu, $submenu; $mask = '%s <span class="update-plugins %s count-%3$s" aria-hidden="true"><span>%3$s<span class="screen-reader-text">%3$s notifications</span></span></span>'; /** * This method is NOT executed for WordPress.org themes. * Since we maintain only one version of the SDK we added this small * hack to avoid the error from Theme Check since it's a false-positive. * * @author Vova Feldman (@svovaf) * @since 1.2.2.7 */ $menu_ref = &$menu; $submenu_ref = &$submenu; if ( $this->_is_top_level ) { // Find main menu item. $found_menu = $this->find_top_level_menu(); if ( false !== $found_menu ) { // Override menu label. $menu_ref[ $found_menu['position'] ][0] = sprintf( $mask, $found_menu['menu'][0], $class, $counter ); } } else { $found_submenu = $this->find_main_submenu(); if ( false !== $found_submenu ) { // Override menu label. $submenu_ref[ $found_submenu['parent_slug'] ][ $found_submenu['position'] ][0] = sprintf( $mask, $found_submenu['menu'][0], $class, $counter ); } } }
php
function add_counter_to_menu_item( $counter = 1, $class = '' ) { global $menu, $submenu; $mask = '%s <span class="update-plugins %s count-%3$s" aria-hidden="true"><span>%3$s<span class="screen-reader-text">%3$s notifications</span></span></span>'; /** * This method is NOT executed for WordPress.org themes. * Since we maintain only one version of the SDK we added this small * hack to avoid the error from Theme Check since it's a false-positive. * * @author Vova Feldman (@svovaf) * @since 1.2.2.7 */ $menu_ref = &$menu; $submenu_ref = &$submenu; if ( $this->_is_top_level ) { // Find main menu item. $found_menu = $this->find_top_level_menu(); if ( false !== $found_menu ) { // Override menu label. $menu_ref[ $found_menu['position'] ][0] = sprintf( $mask, $found_menu['menu'][0], $class, $counter ); } } else { $found_submenu = $this->find_main_submenu(); if ( false !== $found_submenu ) { // Override menu label. $submenu_ref[ $found_submenu['parent_slug'] ][ $found_submenu['position'] ][0] = sprintf( $mask, $found_submenu['menu'][0], $class, $counter ); } } }
[ "function", "add_counter_to_menu_item", "(", "$", "counter", "=", "1", ",", "$", "class", "=", "''", ")", "{", "global", "$", "menu", ",", "$", "submenu", ";", "$", "mask", "=", "'%s <span class=\"update-plugins %s count-%3$s\" aria-hidden=\"true\"><span>%3$s<span cla...
Adds a counter to the module's top level menu item. @author Vova Feldman (@svovaf) @since 1.2.1.5 @param int $counter @param string $class
[ "Adds", "a", "counter", "to", "the", "module", "s", "top", "level", "menu", "item", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L729-L771
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.add_page
static function add_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { $fn = 'add_menu' . '_page'; return $fn( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); }
php
static function add_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { $fn = 'add_menu' . '_page'; return $fn( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); }
[ "static", "function", "add_page", "(", "$", "page_title", ",", "$", "menu_title", ",", "$", "capability", ",", "$", "menu_slug", ",", "$", "function", "=", "''", ",", "$", "icon_url", "=", "''", ",", "$", "position", "=", "null", ")", "{", "$", "fn",...
Add a top-level menu page. Note for WordPress.org Theme/Plugin reviewer: This is a replication of `add_menu_page()` to avoid Theme Check warning. Why? ==== Freemius is an SDK for plugin and theme developers. Since the core of the SDK is relevant both for plugins and themes, for obvious reasons, we only develop and maintain one code base. This method will not run for wp.org themes (only plugins) since theme admin settings/options are now only allowed in the customizer. If you have any questions or need clarifications, please don't hesitate pinging me on slack, my username is @svovaf. @author Vova Feldman (@svovaf) @since 1.2.2 @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. @param string $menu_title The text to be used for the menu. @param string $capability The capability required for this menu to be displayed to the user. @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). @param callable|string $function The function to be called to output the content for this page. @param string $icon_url The URL to the icon to be used for this menu. * Pass a base64-encoded SVG using a data URI, which will be colored to match the color scheme. This should begin with 'data:image/svg+xml;base64,'. * Pass the name of a Dashicons helper class to use a font icon, e.g. 'dashicons-chart-pie'. * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS. @param int $position The position in the menu order this one should appear. @return string The resulting page's hook_suffix.
[ "Add", "a", "top", "-", "level", "menu", "page", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L815-L835
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.add_page_and_update
function add_page_and_update( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { $this->_menu_slug = $menu_slug; $this->_is_top_level = true; $this->_menu_exists = true; $this->_network_menu_exists = true; return self::add_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); }
php
function add_page_and_update( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { $this->_menu_slug = $menu_slug; $this->_is_top_level = true; $this->_menu_exists = true; $this->_network_menu_exists = true; return self::add_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); }
[ "function", "add_page_and_update", "(", "$", "page_title", ",", "$", "menu_title", ",", "$", "capability", ",", "$", "menu_slug", ",", "$", "function", "=", "''", ",", "$", "icon_url", "=", "''", ",", "$", "position", "=", "null", ")", "{", "$", "this"...
Add page and update menu instance settings. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $page_title @param string $menu_title @param string $capability @param string $menu_slug @param callable|string $function @param string $icon_url @param int|null $position @return string
[ "Add", "page", "and", "update", "menu", "instance", "settings", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L853-L876
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.add_subpage
static function add_subpage( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { $fn = 'add_submenu' . '_page'; return $fn( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); }
php
static function add_subpage( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { $fn = 'add_submenu' . '_page'; return $fn( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); }
[ "static", "function", "add_subpage", "(", "$", "parent_slug", ",", "$", "page_title", ",", "$", "menu_title", ",", "$", "capability", ",", "$", "menu_slug", ",", "$", "function", "=", "''", ")", "{", "$", "fn", "=", "'add_submenu'", ".", "'_page'", ";", ...
Add a submenu page. Note for WordPress.org Theme/Plugin reviewer: This is a replication of `add_submenu_page()` to avoid Theme Check warning. Why? ==== Freemius is an SDK for plugin and theme developers. Since the core of the SDK is relevant both for plugins and themes, for obvious reasons, we only develop and maintain one code base. This method will not run for wp.org themes (only plugins) since theme admin settings/options are now only allowed in the customizer. If you have any questions or need clarifications, please don't hesitate pinging me on slack, my username is @svovaf. @author Vova Feldman (@svovaf) @since 1.2.2 @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page). @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. @param string $menu_title The text to be used for the menu. @param string $capability The capability required for this menu to be displayed to the user. @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). @param callable|string $function The function to be called to output the content for this page. @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
[ "Add", "a", "submenu", "page", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L912-L929
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-menu-manager.php
FS_Admin_Menu_Manager.add_subpage_and_update
function add_subpage_and_update( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { $this->_menu_slug = $menu_slug; $this->_parent_slug = $parent_slug; $this->_is_top_level = false; $this->_menu_exists = true; $this->_network_menu_exists = true; return self::add_subpage( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); }
php
function add_subpage_and_update( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { $this->_menu_slug = $menu_slug; $this->_parent_slug = $parent_slug; $this->_is_top_level = false; $this->_menu_exists = true; $this->_network_menu_exists = true; return self::add_subpage( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); }
[ "function", "add_subpage_and_update", "(", "$", "parent_slug", ",", "$", "page_title", ",", "$", "menu_title", ",", "$", "capability", ",", "$", "menu_slug", ",", "$", "function", "=", "''", ")", "{", "$", "this", "->", "_menu_slug", "=", "$", "menu_slug",...
Add sub page and update menu instance settings. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $parent_slug @param string $page_title @param string $menu_title @param string $capability @param string $menu_slug @param callable|string $function @return string
[ "Add", "sub", "page", "and", "update", "menu", "instance", "settings", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-menu-manager.php#L946-L968
train
Freemius/wordpress-sdk
includes/class-fs-admin-notices.php
FS_Admin_Notices.has_sticky
function has_sticky( $id, $network_level_or_blog_id = null ) { if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) { $notices = $this->_network_notices; } else { $notices = $this->get_site_notices( $network_level_or_blog_id ); } return $notices->has_sticky( $id ); }
php
function has_sticky( $id, $network_level_or_blog_id = null ) { if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) { $notices = $this->_network_notices; } else { $notices = $this->get_site_notices( $network_level_or_blog_id ); } return $notices->has_sticky( $id ); }
[ "function", "has_sticky", "(", "$", "id", ",", "$", "network_level_or_blog_id", "=", "null", ")", "{", "if", "(", "$", "this", "->", "should_use_network_notices", "(", "$", "id", ",", "$", "network_level_or_blog_id", ")", ")", "{", "$", "notices", "=", "$"...
Check if sticky message exists by id. @author Vova Feldman (@svovaf) @since 1.0.9 @param string $id @param int|null $network_level_or_blog_id @return bool
[ "Check", "if", "sticky", "message", "exists", "by", "id", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-admin-notices.php#L178-L186
train
Freemius/wordpress-sdk
includes/class-fs-admin-notices.php
FS_Admin_Notices.clear_all_sticky
function clear_all_sticky( $network_level_or_blog_id = null ) { if ( ! $this->_is_multisite || false === $network_level_or_blog_id || 0 == $network_level_or_blog_id || is_null( $network_level_or_blog_id ) ) { $notices = $this->get_site_notices( $network_level_or_blog_id ); $notices->clear_all_sticky(); } if ( $this->_is_multisite && ( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) ) ) { $this->_network_notices->clear_all_sticky(); } }
php
function clear_all_sticky( $network_level_or_blog_id = null ) { if ( ! $this->_is_multisite || false === $network_level_or_blog_id || 0 == $network_level_or_blog_id || is_null( $network_level_or_blog_id ) ) { $notices = $this->get_site_notices( $network_level_or_blog_id ); $notices->clear_all_sticky(); } if ( $this->_is_multisite && ( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) ) ) { $this->_network_notices->clear_all_sticky(); } }
[ "function", "clear_all_sticky", "(", "$", "network_level_or_blog_id", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "_is_multisite", "||", "false", "===", "$", "network_level_or_blog_id", "||", "0", "==", "$", "network_level_or_blog_id", "||", "is_nu...
Clear all sticky messages. @author Vova Feldman (@svovaf) @since 2.0.0 @param int|null $network_level_or_blog_id
[ "Clear", "all", "sticky", "messages", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-admin-notices.php#L231-L246
train
Freemius/wordpress-sdk
includes/class-fs-admin-notices.php
FS_Admin_Notices.add_all
function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) { $this->add( $message, $title, $type, $is_sticky, true, $id ); }
php
function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) { $this->add( $message, $title, $type, $is_sticky, true, $id ); }
[ "function", "add_all", "(", "$", "message", ",", "$", "title", "=", "''", ",", "$", "type", "=", "'success'", ",", "$", "is_sticky", "=", "false", ",", "$", "id", "=", "''", ")", "{", "$", "this", "->", "add", "(", "$", "message", ",", "$", "ti...
Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked. @author Vova Feldman (@svovaf) @since 1.0.4 @param string $message @param string $title @param string $type @param bool $is_sticky @param string $id Message ID
[ "Add", "admin", "message", "to", "all", "admin", "messages", "queue", "and", "hook", "to", "all_admin_notices", "if", "not", "yet", "hooked", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-admin-notices.php#L260-L262
train
Freemius/wordpress-sdk
includes/class-fs-admin-notices.php
FS_Admin_Notices.should_use_network_notices
private function should_use_network_notices( $id = '', $network_level_or_blog_id = null ) { if ( ! $this->_is_multisite ) { // Not a multisite environment. return false; } if ( is_numeric( $network_level_or_blog_id ) ) { // Explicitly asked to use a specified blog storage. return false; } if ( is_bool( $network_level_or_blog_id ) ) { // Explicitly specified whether should use the network or blog level storage. return $network_level_or_blog_id; } return fs_is_network_admin(); }
php
private function should_use_network_notices( $id = '', $network_level_or_blog_id = null ) { if ( ! $this->_is_multisite ) { // Not a multisite environment. return false; } if ( is_numeric( $network_level_or_blog_id ) ) { // Explicitly asked to use a specified blog storage. return false; } if ( is_bool( $network_level_or_blog_id ) ) { // Explicitly specified whether should use the network or blog level storage. return $network_level_or_blog_id; } return fs_is_network_admin(); }
[ "private", "function", "should_use_network_notices", "(", "$", "id", "=", "''", ",", "$", "network_level_or_blog_id", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "_is_multisite", ")", "{", "// Not a multisite environment.", "return", "false", ";", ...
Check if the network notices should be used. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $id @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite notices (if there's a network). When `false`, use the current context blog notices. When `null`, the decision which notices manager to use (MS vs. Current S) will be handled internally and determined based on the $id and the context admin (blog admin vs. network level admin). @return bool
[ "Check", "if", "the", "network", "notices", "should", "be", "used", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-admin-notices.php#L301-L318
train
Freemius/wordpress-sdk
includes/managers/class-fs-option-manager.php
FS_Option_Manager.delete
function delete() { $option_name = $this->get_option_manager_name(); if ( $this->_is_network_storage ) { delete_site_option( $option_name ); } else if ( $this->_blog_id > 0 ) { delete_blog_option( $this->_blog_id, $option_name ); } else { delete_option( $option_name ); } }
php
function delete() { $option_name = $this->get_option_manager_name(); if ( $this->_is_network_storage ) { delete_site_option( $option_name ); } else if ( $this->_blog_id > 0 ) { delete_blog_option( $this->_blog_id, $option_name ); } else { delete_option( $option_name ); } }
[ "function", "delete", "(", ")", "{", "$", "option_name", "=", "$", "this", "->", "get_option_manager_name", "(", ")", ";", "if", "(", "$", "this", "->", "_is_network_storage", ")", "{", "delete_site_option", "(", "$", "option_name", ")", ";", "}", "else", ...
Delete options manager from DB. @author Vova Feldman (@svovaf) @since 1.0.9
[ "Delete", "options", "manager", "from", "DB", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-option-manager.php#L227-L237
train
Freemius/wordpress-sdk
includes/managers/class-fs-option-manager.php
FS_Option_Manager.unset_option
function unset_option( $option, $flush = false ) { $this->_logger->entrance( 'option = ' . $option ); if ( is_array( $this->_options ) ) { if ( ! isset( $this->_options[ $option ] ) ) { return; } unset( $this->_options[ $option ] ); } else if ( is_object( $this->_options ) ) { if ( ! isset( $this->_options->{$option} ) ) { return; } unset( $this->_options->{$option} ); } if ( $flush ) { $this->store(); } }
php
function unset_option( $option, $flush = false ) { $this->_logger->entrance( 'option = ' . $option ); if ( is_array( $this->_options ) ) { if ( ! isset( $this->_options[ $option ] ) ) { return; } unset( $this->_options[ $option ] ); } else if ( is_object( $this->_options ) ) { if ( ! isset( $this->_options->{$option} ) ) { return; } unset( $this->_options->{$option} ); } if ( $flush ) { $this->store(); } }
[ "function", "unset_option", "(", "$", "option", ",", "$", "flush", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "'option = '", ".", "$", "option", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "_options", ")...
Unset option. @author Vova Feldman (@svovaf) @since 1.0.3 @param string $option @param bool $flush
[ "Unset", "option", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-option-manager.php#L362-L383
train
Freemius/wordpress-sdk
includes/managers/class-fs-option-manager.php
FS_Option_Manager.store
function store() { $this->_logger->entrance(); $option_name = $this->get_option_manager_name(); if ( $this->_logger->is_on() ) { $this->_logger->info( $option_name . ' = ' . var_export( $this->_options, true ) ); } // Update DB. if ( $this->_is_network_storage ) { update_site_option( $option_name, $this->_options ); } else if ( $this->_blog_id > 0 ) { update_blog_option( $this->_blog_id, $option_name, $this->_options ); } else { update_option( $option_name, $this->_options ); } if ( ! WP_FS__DEBUG_SDK ) { wp_cache_set( $option_name, $this->_options, $this->get_cache_group() ); } }
php
function store() { $this->_logger->entrance(); $option_name = $this->get_option_manager_name(); if ( $this->_logger->is_on() ) { $this->_logger->info( $option_name . ' = ' . var_export( $this->_options, true ) ); } // Update DB. if ( $this->_is_network_storage ) { update_site_option( $option_name, $this->_options ); } else if ( $this->_blog_id > 0 ) { update_blog_option( $this->_blog_id, $option_name, $this->_options ); } else { update_option( $option_name, $this->_options ); } if ( ! WP_FS__DEBUG_SDK ) { wp_cache_set( $option_name, $this->_options, $this->get_cache_group() ); } }
[ "function", "store", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "option_name", "=", "$", "this", "->", "get_option_manager_name", "(", ")", ";", "if", "(", "$", "this", "->", "_logger", "->", "is_on", "(", ")",...
Dump options to database. @author Vova Feldman (@svovaf) @since 1.0.3
[ "Dump", "options", "to", "database", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-option-manager.php#L391-L412
train
Freemius/wordpress-sdk
includes/managers/class-fs-option-manager.php
FS_Option_Manager.get_options_keys
function get_options_keys() { if ( is_array( $this->_options ) ) { return array_keys( $this->_options ); } else if ( is_object( $this->_options ) ) { return array_keys( get_object_vars( $this->_options ) ); } return array(); }
php
function get_options_keys() { if ( is_array( $this->_options ) ) { return array_keys( $this->_options ); } else if ( is_object( $this->_options ) ) { return array_keys( get_object_vars( $this->_options ) ); } return array(); }
[ "function", "get_options_keys", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_options", ")", ")", "{", "return", "array_keys", "(", "$", "this", "->", "_options", ")", ";", "}", "else", "if", "(", "is_object", "(", "$", "this", "->"...
Get options keys. @author Vova Feldman (@svovaf) @since 1.0.3 @return string[]
[ "Get", "options", "keys", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-option-manager.php#L422-L430
train
Freemius/wordpress-sdk
includes/managers/class-fs-option-manager.php
FS_Option_Manager.migrate_to_network
function migrate_to_network() { $site_options = FS_Option_Manager::get_manager($this->_id, true, false); $options = is_object( $site_options->_options ) ? get_object_vars( $site_options->_options ) : $site_options->_options; if ( ! empty( $options ) ) { foreach ( $options as $key => $val ) { $this->set_option( $key, $val, false ); } $this->store(); } }
php
function migrate_to_network() { $site_options = FS_Option_Manager::get_manager($this->_id, true, false); $options = is_object( $site_options->_options ) ? get_object_vars( $site_options->_options ) : $site_options->_options; if ( ! empty( $options ) ) { foreach ( $options as $key => $val ) { $this->set_option( $key, $val, false ); } $this->store(); } }
[ "function", "migrate_to_network", "(", ")", "{", "$", "site_options", "=", "FS_Option_Manager", "::", "get_manager", "(", "$", "this", "->", "_id", ",", "true", ",", "false", ")", ";", "$", "options", "=", "is_object", "(", "$", "site_options", "->", "_opt...
Migrate options from site level. @author Vova Feldman (@svovaf) @since 2.0.0
[ "Migrate", "options", "from", "site", "level", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-option-manager.php#L442-L456
train
Freemius/wordpress-sdk
includes/class-fs-storage.php
FS_Storage.set_site_blog_context
function set_site_blog_context( $blog_id ) { $this->_storage = $this->get_site_storage( $blog_id ); $this->_blog_id = $blog_id; }
php
function set_site_blog_context( $blog_id ) { $this->_storage = $this->get_site_storage( $blog_id ); $this->_blog_id = $blog_id; }
[ "function", "set_site_blog_context", "(", "$", "blog_id", ")", "{", "$", "this", "->", "_storage", "=", "$", "this", "->", "get_site_storage", "(", "$", "blog_id", ")", ";", "$", "this", "->", "_blog_id", "=", "$", "blog_id", ";", "}" ]
Switch the context of the site level storage manager. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id
[ "Switch", "the", "context", "of", "the", "site", "level", "storage", "manager", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-storage.php#L134-L137
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-notice-manager.php
FS_Admin_Notice_Manager._admin_notices_hook
function _admin_notices_hook() { if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) { // Only show messages to admins. return; } $show_admin_notices = ( ! $this->is_gutenberg_page() ); foreach ( $this->_notices as $id => $msg ) { if ( isset( $msg['wp_user_id'] ) && is_numeric( $msg['wp_user_id'] ) ) { if ( get_current_user_id() != $msg['wp_user_id'] ) { continue; } } /** * Added a filter to control the visibility of admin notices. * * Usage example: * * /** * * @param bool $show * * @param array $msg { * * @var string $message The actual message. * * @var string $title An optional message title. * * @var string $type The type of the message ('success', 'update', 'warning', 'promotion'). * * @var string $id The unique identifier of the message. * * @var string $manager_id The unique identifier of the notices manager. For plugins it would be the plugin's slug, for themes - `<slug>-theme`. * * @var string $plugin The product's title. * * @var string $wp_user_id An optional WP user ID that this admin notice is for. * * } * * * * @return bool * *\/ * function my_custom_show_admin_notice( $show, $msg ) { * if ('trial_promotion' != $msg['id']) { * return false; * } * * return $show; * } * * my_fs()->add_filter( 'show_admin_notice', 'my_custom_show_admin_notice', 10, 2 ); * * @author Vova Feldman * @since 2.2.0 */ $show_notice = call_user_func_array( 'fs_apply_filter', array( $this->_module_unique_affix, 'show_admin_notice', $show_admin_notices, $msg ) ); if ( true !== $show_notice ) { continue; } fs_require_template( 'admin-notice.php', $msg ); if ( $msg['sticky'] ) { self::has_sticky_messages(); } } }
php
function _admin_notices_hook() { if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) { // Only show messages to admins. return; } $show_admin_notices = ( ! $this->is_gutenberg_page() ); foreach ( $this->_notices as $id => $msg ) { if ( isset( $msg['wp_user_id'] ) && is_numeric( $msg['wp_user_id'] ) ) { if ( get_current_user_id() != $msg['wp_user_id'] ) { continue; } } /** * Added a filter to control the visibility of admin notices. * * Usage example: * * /** * * @param bool $show * * @param array $msg { * * @var string $message The actual message. * * @var string $title An optional message title. * * @var string $type The type of the message ('success', 'update', 'warning', 'promotion'). * * @var string $id The unique identifier of the message. * * @var string $manager_id The unique identifier of the notices manager. For plugins it would be the plugin's slug, for themes - `<slug>-theme`. * * @var string $plugin The product's title. * * @var string $wp_user_id An optional WP user ID that this admin notice is for. * * } * * * * @return bool * *\/ * function my_custom_show_admin_notice( $show, $msg ) { * if ('trial_promotion' != $msg['id']) { * return false; * } * * return $show; * } * * my_fs()->add_filter( 'show_admin_notice', 'my_custom_show_admin_notice', 10, 2 ); * * @author Vova Feldman * @since 2.2.0 */ $show_notice = call_user_func_array( 'fs_apply_filter', array( $this->_module_unique_affix, 'show_admin_notice', $show_admin_notices, $msg ) ); if ( true !== $show_notice ) { continue; } fs_require_template( 'admin-notice.php', $msg ); if ( $msg['sticky'] ) { self::has_sticky_messages(); } } }
[ "function", "_admin_notices_hook", "(", ")", "{", "if", "(", "function_exists", "(", "'current_user_can'", ")", "&&", "!", "current_user_can", "(", "'manage_options'", ")", ")", "{", "// Only show messages to admins.\r", "return", ";", "}", "$", "show_admin_notices", ...
Handle admin_notices by printing the admin messages stacked in the queue. @author Vova Feldman (@svovaf) @since 1.0.4
[ "Handle", "admin_notices", "by", "printing", "the", "admin", "messages", "stacked", "in", "the", "queue", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-notice-manager.php#L214-L281
train
Freemius/wordpress-sdk
includes/managers/class-fs-admin-notice-manager.php
FS_Admin_Notice_Manager.is_gutenberg_page
function is_gutenberg_page() { if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // The Gutenberg plugin is on. return true; } $current_screen = get_current_screen(); if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { // Gutenberg page on 5+. return true; } return false; }
php
function is_gutenberg_page() { if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // The Gutenberg plugin is on. return true; } $current_screen = get_current_screen(); if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { // Gutenberg page on 5+. return true; } return false; }
[ "function", "is_gutenberg_page", "(", ")", "{", "if", "(", "function_exists", "(", "'is_gutenberg_page'", ")", "&&", "is_gutenberg_page", "(", ")", ")", "{", "// The Gutenberg plugin is on.\r", "return", "true", ";", "}", "$", "current_screen", "=", "get_current_scr...
Check if the current page is the Gutenberg block editor. @author Vova Feldman (@svovaf) @since 2.2.3 @return bool
[ "Check", "if", "the", "current", "page", "is", "the", "Gutenberg", "block", "editor", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-admin-notice-manager.php#L301-L319
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.filters
private function filters() { // Override request for plugin information add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 ); $this->add_transient_filters(); /** * If user has the premium plugin's code but do NOT have an active license, * encourage him to upgrade by showing that there's a new release, but instead * of showing an update link, show upgrade link to the pricing page. * * @since 1.1.6 * */ // WP 2.9+ add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array( &$this, 'catch_plugin_update_row' ), 9 ); add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array( &$this, 'edit_and_echo_plugin_update_row' ), 11, 2 ); add_action( 'admin_head', array( &$this, 'catch_plugin_information_dialog_contents' ) ); if ( ! WP_FS__IS_PRODUCTION_MODE ) { add_filter( 'http_request_host_is_external', array( $this, 'http_request_host_is_external_filter' ), 10, 3 ); } if ( $this->_fs->is_premium() ) { if ( ! $this->is_correct_folder_name() ) { add_filter( 'upgrader_post_install', array( &$this, '_maybe_update_folder_name' ), 10, 3 ); } add_filter( 'upgrader_pre_install', array( 'FS_Plugin_Updater', '_store_basename_for_source_adjustment' ), 1, 2 ); add_filter( 'upgrader_source_selection', array( 'FS_Plugin_Updater', '_maybe_adjust_source_dir' ), 1, 3 ); if ( ! $this->_fs->has_any_active_valid_license() ) { add_filter( 'wp_prepare_themes_for_js', array( &$this, 'change_theme_update_info_html' ), 10, 1 ); } } }
php
private function filters() { // Override request for plugin information add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 ); $this->add_transient_filters(); /** * If user has the premium plugin's code but do NOT have an active license, * encourage him to upgrade by showing that there's a new release, but instead * of showing an update link, show upgrade link to the pricing page. * * @since 1.1.6 * */ // WP 2.9+ add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array( &$this, 'catch_plugin_update_row' ), 9 ); add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array( &$this, 'edit_and_echo_plugin_update_row' ), 11, 2 ); add_action( 'admin_head', array( &$this, 'catch_plugin_information_dialog_contents' ) ); if ( ! WP_FS__IS_PRODUCTION_MODE ) { add_filter( 'http_request_host_is_external', array( $this, 'http_request_host_is_external_filter' ), 10, 3 ); } if ( $this->_fs->is_premium() ) { if ( ! $this->is_correct_folder_name() ) { add_filter( 'upgrader_post_install', array( &$this, '_maybe_update_folder_name' ), 10, 3 ); } add_filter( 'upgrader_pre_install', array( 'FS_Plugin_Updater', '_store_basename_for_source_adjustment' ), 1, 2 ); add_filter( 'upgrader_source_selection', array( 'FS_Plugin_Updater', '_maybe_adjust_source_dir' ), 1, 3 ); if ( ! $this->_fs->has_any_active_valid_license() ) { add_filter( 'wp_prepare_themes_for_js', array( &$this, 'change_theme_update_info_html' ), 10, 1 ); } } }
[ "private", "function", "filters", "(", ")", "{", "// Override request for plugin information\r", "add_filter", "(", "'plugins_api'", ",", "array", "(", "&", "$", "this", ",", "'plugins_api_filter'", ")", ",", "10", ",", "3", ")", ";", "$", "this", "->", "add_t...
Initiate required filters. @author Vova Feldman (@svovaf) @since 1.0.4
[ "Initiate", "required", "filters", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L81-L126
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.edit_and_echo_plugin_update_row
function edit_and_echo_plugin_update_row( $file, $plugin_data ) { $plugin_update_row = ob_get_clean(); $current = get_site_transient( 'update_plugins' ); if ( ! isset( $current->response[ $file ] ) ) { echo $plugin_update_row; return; } $r = $current->response[ $file ]; if ( ! $this->_fs->has_any_active_valid_license() ) { /** * Turn the "new version" text into a link that opens the plugin information dialog when clicked and * make the "View version x details" text link to the checkout page instead of opening the plugin * information dialog when clicked. * * Sample input: * There is a new version of Awesome Plugin available. <a href="...>View version x.y.z details</a> or <a href="...>update now</a>. * Output: * There is a <a href="...>new version</a> of Awesome Plugin available. <a href="...>Buy a license now</a> to access version x.y.z security & feature updates, and support. * * @author Leo Fajardo (@leorw) */ $plugin_update_row = preg_replace( '/(\<div.+>)(.+)(\<a.+href="([^\s]+)"([^\<]+)\>.+\<a.+)(\<\/div\>)/is', ( '$1' . sprintf( fs_text_inline( 'There is a %s of %s available.', 'new-version-available', $this->_fs->get_slug() ), sprintf( '<a href="$4"%s>%s</a>', '$5', fs_text_inline( 'new version', 'new-version', $this->_fs->get_slug() ) ), $this->_fs->get_plugin_title() ) . ' ' . $this->_fs->version_upgrade_checkout_link( $r->new_version ) . '$6' ), $plugin_update_row ); } if ( $this->_fs->is_plugin() && isset( $r->upgrade_notice ) && strlen( trim( $r->upgrade_notice ) ) > 0 ) { $slug = $this->_fs->get_slug(); $upgrade_notice_html = sprintf( '<p class="notice fs-upgrade-notice fs-slug-%1s fs-type-%2s" data-slug="%1s" data-type="%2s"><strong>%3s</strong> %4s</p>', $slug, $this->_fs->get_module_type(), fs_text_inline( 'Important Upgrade Notice:', 'upgrade_notice', $slug ), esc_html( $r->upgrade_notice ) ); $plugin_update_row = str_replace( '</div>', '</div>' . $upgrade_notice_html, $plugin_update_row ); } echo $plugin_update_row; }
php
function edit_and_echo_plugin_update_row( $file, $plugin_data ) { $plugin_update_row = ob_get_clean(); $current = get_site_transient( 'update_plugins' ); if ( ! isset( $current->response[ $file ] ) ) { echo $plugin_update_row; return; } $r = $current->response[ $file ]; if ( ! $this->_fs->has_any_active_valid_license() ) { /** * Turn the "new version" text into a link that opens the plugin information dialog when clicked and * make the "View version x details" text link to the checkout page instead of opening the plugin * information dialog when clicked. * * Sample input: * There is a new version of Awesome Plugin available. <a href="...>View version x.y.z details</a> or <a href="...>update now</a>. * Output: * There is a <a href="...>new version</a> of Awesome Plugin available. <a href="...>Buy a license now</a> to access version x.y.z security & feature updates, and support. * * @author Leo Fajardo (@leorw) */ $plugin_update_row = preg_replace( '/(\<div.+>)(.+)(\<a.+href="([^\s]+)"([^\<]+)\>.+\<a.+)(\<\/div\>)/is', ( '$1' . sprintf( fs_text_inline( 'There is a %s of %s available.', 'new-version-available', $this->_fs->get_slug() ), sprintf( '<a href="$4"%s>%s</a>', '$5', fs_text_inline( 'new version', 'new-version', $this->_fs->get_slug() ) ), $this->_fs->get_plugin_title() ) . ' ' . $this->_fs->version_upgrade_checkout_link( $r->new_version ) . '$6' ), $plugin_update_row ); } if ( $this->_fs->is_plugin() && isset( $r->upgrade_notice ) && strlen( trim( $r->upgrade_notice ) ) > 0 ) { $slug = $this->_fs->get_slug(); $upgrade_notice_html = sprintf( '<p class="notice fs-upgrade-notice fs-slug-%1s fs-type-%2s" data-slug="%1s" data-type="%2s"><strong>%3s</strong> %4s</p>', $slug, $this->_fs->get_module_type(), fs_text_inline( 'Important Upgrade Notice:', 'upgrade_notice', $slug ), esc_html( $r->upgrade_notice ) ); $plugin_update_row = str_replace( '</div>', '</div>' . $upgrade_notice_html, $plugin_update_row ); } echo $plugin_update_row; }
[ "function", "edit_and_echo_plugin_update_row", "(", "$", "file", ",", "$", "plugin_data", ")", "{", "$", "plugin_update_row", "=", "ob_get_clean", "(", ")", ";", "$", "current", "=", "get_site_transient", "(", "'update_plugins'", ")", ";", "if", "(", "!", "iss...
Overrides default update message format with "renew your license" message. @author Vova Feldman (@svovaf) @since 1.1.6 @param string $file @param array $plugin_data
[ "Overrides", "default", "update", "message", "format", "with", "renew", "your", "license", "message", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L248-L313
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.get_update_details
function get_update_details( FS_Plugin_Tag $new_version ) { $update = new stdClass(); $update->slug = $this->_fs->get_slug(); $update->new_version = $new_version->version; $update->url = WP_FS__ADDRESS; $update->package = $new_version->url; $update->tested = $new_version->tested_up_to_version; $update->requires = $new_version->requires_platform_version; $icon = $this->_fs->get_local_icon_url(); if ( ! empty( $icon ) ) { $update->icons = array( // '1x' => $icon, // '2x' => $icon, 'default' => $icon, ); } if ( $this->_fs->is_premium() ) { $latest_tag = $this->_fs->_fetch_latest_version( $this->_fs->get_id(), false ); if ( isset( $latest_tag->readme ) && isset( $latest_tag->readme->upgrade_notice ) && ! empty( $latest_tag->readme->upgrade_notice ) ) { $update->upgrade_notice = $latest_tag->readme->upgrade_notice; } } $update->{$this->_fs->get_module_type()} = $this->_fs->get_plugin_basename(); return $update; }
php
function get_update_details( FS_Plugin_Tag $new_version ) { $update = new stdClass(); $update->slug = $this->_fs->get_slug(); $update->new_version = $new_version->version; $update->url = WP_FS__ADDRESS; $update->package = $new_version->url; $update->tested = $new_version->tested_up_to_version; $update->requires = $new_version->requires_platform_version; $icon = $this->_fs->get_local_icon_url(); if ( ! empty( $icon ) ) { $update->icons = array( // '1x' => $icon, // '2x' => $icon, 'default' => $icon, ); } if ( $this->_fs->is_premium() ) { $latest_tag = $this->_fs->_fetch_latest_version( $this->_fs->get_id(), false ); if ( isset( $latest_tag->readme ) && isset( $latest_tag->readme->upgrade_notice ) && ! empty( $latest_tag->readme->upgrade_notice ) ) { $update->upgrade_notice = $latest_tag->readme->upgrade_notice; } } $update->{$this->_fs->get_module_type()} = $this->_fs->get_plugin_basename(); return $update; }
[ "function", "get_update_details", "(", "FS_Plugin_Tag", "$", "new_version", ")", "{", "$", "update", "=", "new", "stdClass", "(", ")", ";", "$", "update", "->", "slug", "=", "$", "this", "->", "_fs", "->", "get_slug", "(", ")", ";", "$", "update", "->"...
Get module's required data for the updates mechanism. @author Vova Feldman (@svovaf) @since 2.0.0 @param \FS_Plugin_Tag $new_version @return object
[ "Get", "module", "s", "required", "data", "for", "the", "updates", "mechanism", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L499-L533
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.set_update_data
function set_update_data( FS_Plugin_Tag $new_version ) { $this->_logger->entrance(); $transient_key = "update_{$this->_fs->get_module_type()}s"; $transient_data = get_site_transient( $transient_key ); $transient_data = is_object( $transient_data ) ? $transient_data : new stdClass(); // Alias. $basename = $this->_fs->get_plugin_basename(); $is_plugin = $this->_fs->is_plugin(); if ( ! isset( $transient_data->response ) || ! is_array( $transient_data->response ) ) { $transient_data->response = array(); } else if ( ! empty( $transient_data->response[ $basename ] ) ) { $version = $is_plugin ? ( ! empty( $transient_data->response[ $basename ]->new_version ) ? $transient_data->response[ $basename ]->new_version : null ) : ( ! empty( $transient_data->response[ $basename ]['new_version'] ) ? $transient_data->response[ $basename ]['new_version'] : null ); if ( $version == $new_version->version ) { // The update data is already set. return; } } // Remove the added filters. $this->remove_transient_filters(); $this->_update_details = $this->get_update_details( $new_version ); // Set update data in transient. $transient_data->response[ $basename ] = $is_plugin ? $this->_update_details : (array) $this->_update_details; if ( ! isset( $transient_data->checked ) || ! is_array( $transient_data->checked ) ) { $transient_data->checked = array(); } // Flag the module as if it was already checked. $transient_data->checked[ $basename ] = $this->_fs->get_plugin_version(); $transient_data->last_checked = time(); set_site_transient( $transient_key, $transient_data ); $this->add_transient_filters(); }
php
function set_update_data( FS_Plugin_Tag $new_version ) { $this->_logger->entrance(); $transient_key = "update_{$this->_fs->get_module_type()}s"; $transient_data = get_site_transient( $transient_key ); $transient_data = is_object( $transient_data ) ? $transient_data : new stdClass(); // Alias. $basename = $this->_fs->get_plugin_basename(); $is_plugin = $this->_fs->is_plugin(); if ( ! isset( $transient_data->response ) || ! is_array( $transient_data->response ) ) { $transient_data->response = array(); } else if ( ! empty( $transient_data->response[ $basename ] ) ) { $version = $is_plugin ? ( ! empty( $transient_data->response[ $basename ]->new_version ) ? $transient_data->response[ $basename ]->new_version : null ) : ( ! empty( $transient_data->response[ $basename ]['new_version'] ) ? $transient_data->response[ $basename ]['new_version'] : null ); if ( $version == $new_version->version ) { // The update data is already set. return; } } // Remove the added filters. $this->remove_transient_filters(); $this->_update_details = $this->get_update_details( $new_version ); // Set update data in transient. $transient_data->response[ $basename ] = $is_plugin ? $this->_update_details : (array) $this->_update_details; if ( ! isset( $transient_data->checked ) || ! is_array( $transient_data->checked ) ) { $transient_data->checked = array(); } // Flag the module as if it was already checked. $transient_data->checked[ $basename ] = $this->_fs->get_plugin_version(); $transient_data->last_checked = time(); set_site_transient( $transient_key, $transient_data ); $this->add_transient_filters(); }
[ "function", "set_update_data", "(", "FS_Plugin_Tag", "$", "new_version", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "transient_key", "=", "\"update_{$this->_fs->get_module_type()}s\"", ";", "$", "transient_data", "=", "get_site_tra...
Update the updates transient with the module's update information. This method is required for multisite environment. If a module is site activated (not network) and not on the main site, the module will NOT be executed on the network level, therefore, the custom updates logic will not be executed as well, so unless we force the injection of the update into the updates transient, premium updates will not work. @author Vova Feldman (@svovaf) @since 2.0.0 @param \FS_Plugin_Tag $new_version
[ "Update", "the", "updates", "transient", "with", "the", "module", "s", "update", "information", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L550-L608
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater._fetch_plugin_info_from_repository
static function _fetch_plugin_info_from_repository( $action, $args ) { $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { $url = set_url_scheme( $url, 'https' ); } $args = array( 'timeout' => 15, 'body' => array( 'action' => $action, 'request' => serialize( $args ) ) ); $request = wp_remote_post( $url, $args ); if ( is_wp_error( $request ) ) { return false; } $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); if ( ! is_object( $res ) && ! is_array( $res ) ) { return false; } return $res; }
php
static function _fetch_plugin_info_from_repository( $action, $args ) { $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { $url = set_url_scheme( $url, 'https' ); } $args = array( 'timeout' => 15, 'body' => array( 'action' => $action, 'request' => serialize( $args ) ) ); $request = wp_remote_post( $url, $args ); if ( is_wp_error( $request ) ) { return false; } $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); if ( ! is_object( $res ) && ! is_array( $res ) ) { return false; } return $res; }
[ "static", "function", "_fetch_plugin_info_from_repository", "(", "$", "action", ",", "$", "args", ")", "{", "$", "url", "=", "$", "http_url", "=", "'http://api.wordpress.org/plugins/info/1.0/'", ";", "if", "(", "$", "ssl", "=", "wp_http_supports", "(", "array", ...
Try to fetch plugin's info from .org repository. @author Vova Feldman (@svovaf) @since 1.0.5 @param string $action @param object $args @return bool|mixed
[ "Try", "to", "fetch", "plugin", "s", "info", "from", ".", "org", "repository", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L653-L680
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.fetch_wp_org_module_translation_updates
private function fetch_wp_org_module_translation_updates( $module_type, $slug ) { $plugin_data = $this->_fs->get_plugin_data(); $locales = array_values( get_available_languages() ); $locales = apply_filters( "{$module_type}_update_check_locales", $locales ); $locales = array_unique( $locales ); $plugin_basename = $this->_fs->get_plugin_basename(); if ( 'themes' === $module_type ) { $plugin_basename = $slug; } global $wp_version; $request_args = array( 'timeout' => 15, 'body' => array( "{$module_type}" => json_encode( array( "{$module_type}" => array( $plugin_basename => array( 'Name' => trim( str_replace( $this->_fs->get_plugin()->premium_suffix, '', $plugin_data['Name'] ) ), 'Author' => $plugin_data['Author'], ) ) ) ), 'translations' => json_encode( $this->get_installed_translations( $module_type, $slug ) ), 'locale' => json_encode( $locales ) ), 'user-agent' => ( 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ) ); $url = "http://api.wordpress.org/{$module_type}/update-check/1.1/"; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { $url = set_url_scheme( $url, 'https' ); } $raw_response = Freemius::safe_remote_post( $url, $request_args, WP_FS__TIME_24_HOURS_IN_SEC, WP_FS__TIME_12_HOURS_IN_SEC, false ); if ( is_wp_error( $raw_response ) ) { return null; } $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); if ( ! is_array( $response ) ) { return null; } if ( ! isset( $response['translations'] ) || empty( $response['translations'] ) ) { return null; } return $response['translations']; }
php
private function fetch_wp_org_module_translation_updates( $module_type, $slug ) { $plugin_data = $this->_fs->get_plugin_data(); $locales = array_values( get_available_languages() ); $locales = apply_filters( "{$module_type}_update_check_locales", $locales ); $locales = array_unique( $locales ); $plugin_basename = $this->_fs->get_plugin_basename(); if ( 'themes' === $module_type ) { $plugin_basename = $slug; } global $wp_version; $request_args = array( 'timeout' => 15, 'body' => array( "{$module_type}" => json_encode( array( "{$module_type}" => array( $plugin_basename => array( 'Name' => trim( str_replace( $this->_fs->get_plugin()->premium_suffix, '', $plugin_data['Name'] ) ), 'Author' => $plugin_data['Author'], ) ) ) ), 'translations' => json_encode( $this->get_installed_translations( $module_type, $slug ) ), 'locale' => json_encode( $locales ) ), 'user-agent' => ( 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ) ); $url = "http://api.wordpress.org/{$module_type}/update-check/1.1/"; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { $url = set_url_scheme( $url, 'https' ); } $raw_response = Freemius::safe_remote_post( $url, $request_args, WP_FS__TIME_24_HOURS_IN_SEC, WP_FS__TIME_12_HOURS_IN_SEC, false ); if ( is_wp_error( $raw_response ) ) { return null; } $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); if ( ! is_array( $response ) ) { return null; } if ( ! isset( $response['translations'] ) || empty( $response['translations'] ) ) { return null; } return $response['translations']; }
[ "private", "function", "fetch_wp_org_module_translation_updates", "(", "$", "module_type", ",", "$", "slug", ")", "{", "$", "plugin_data", "=", "$", "this", "->", "_fs", "->", "get_plugin_data", "(", ")", ";", "$", "locales", "=", "array_values", "(", "get_ava...
Fetches module translation updates from wordpress.org. @author Leo Fajardo (@leorw) @since 2.1.2 @param string $module_type @param string $slug @return array|null
[ "Fetches", "module", "translation", "updates", "from", "wordpress", ".", "org", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L693-L754
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater._maybe_update_folder_name
function _maybe_update_folder_name( $response, $hook_extra, $result ) { $basename = $this->_fs->get_plugin_basename(); if ( true !== $response || empty( $hook_extra ) || empty( $hook_extra['plugin'] ) || $basename !== $hook_extra['plugin'] ) { return $response; } $active_plugins_basenames = get_option( 'active_plugins' ); for ( $i = 0, $len = count( $active_plugins_basenames ); $i < $len; $i ++ ) { if ( $basename === $active_plugins_basenames[ $i ] ) { // Get filename including extension. $filename = basename( $basename ); $new_basename = plugin_basename( trailingslashit( $this->_fs->is_premium() ? $this->_fs->get_premium_slug() : $this->_fs->get_slug() ) . $filename ); // Verify that the expected correct path exists. if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $new_basename ) ) ) { // Override active plugin name. $active_plugins_basenames[ $i ] = $new_basename; update_option( 'active_plugins', $active_plugins_basenames ); } break; } } return $response; }
php
function _maybe_update_folder_name( $response, $hook_extra, $result ) { $basename = $this->_fs->get_plugin_basename(); if ( true !== $response || empty( $hook_extra ) || empty( $hook_extra['plugin'] ) || $basename !== $hook_extra['plugin'] ) { return $response; } $active_plugins_basenames = get_option( 'active_plugins' ); for ( $i = 0, $len = count( $active_plugins_basenames ); $i < $len; $i ++ ) { if ( $basename === $active_plugins_basenames[ $i ] ) { // Get filename including extension. $filename = basename( $basename ); $new_basename = plugin_basename( trailingslashit( $this->_fs->is_premium() ? $this->_fs->get_premium_slug() : $this->_fs->get_slug() ) . $filename ); // Verify that the expected correct path exists. if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $new_basename ) ) ) { // Override active plugin name. $active_plugins_basenames[ $i ] = $new_basename; update_option( 'active_plugins', $active_plugins_basenames ); } break; } } return $response; }
[ "function", "_maybe_update_folder_name", "(", "$", "response", ",", "$", "hook_extra", ",", "$", "result", ")", "{", "$", "basename", "=", "$", "this", "->", "_fs", "->", "get_plugin_basename", "(", ")", ";", "if", "(", "true", "!==", "$", "response", "|...
This is a special after upgrade handler for migrating modules that didn't use the '-premium' suffix folder structure before the migration. @author Vova Feldman (@svovaf) @since 1.2.1.6 @param bool $response Install response. @param array $hook_extra Extra arguments passed to hooked filters. @param array $result Installation result data. @return bool
[ "This", "is", "a", "special", "after", "upgrade", "handler", "for", "migrating", "modules", "that", "didn", "t", "use", "the", "-", "premium", "suffix", "folder", "structure", "before", "the", "migration", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L992-L1027
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.try_activate_plugin
protected function try_activate_plugin( $file_path ) { $activate = activate_plugin( $file_path, '', $this->_fs->is_network_active() ); return is_wp_error( $activate ) ? $activate : true; }
php
protected function try_activate_plugin( $file_path ) { $activate = activate_plugin( $file_path, '', $this->_fs->is_network_active() ); return is_wp_error( $activate ) ? $activate : true; }
[ "protected", "function", "try_activate_plugin", "(", "$", "file_path", ")", "{", "$", "activate", "=", "activate_plugin", "(", "$", "file_path", ",", "''", ",", "$", "this", "->", "_fs", "->", "is_network_active", "(", ")", ")", ";", "return", "is_wp_error",...
Tries to activate a plugin. If fails, returns the error. @author Vova Feldman @since 1.2.1.7 @param string $file_path Path within wp-plugins/ to main plugin file. This determines the styling of the output messages. @return bool|WP_Error
[ "Tries", "to", "activate", "a", "plugin", ".", "If", "fails", "returns", "the", "error", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L1209-L1215
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater.is_premium_plugin_active
private function is_premium_plugin_active( $plugin_id = false ) { if ( $plugin_id != $this->_fs->get_id() ) { return $this->_fs->is_addon_activated( $plugin_id, true ); } return is_plugin_active( $this->_fs->premium_plugin_basename() ); }
php
private function is_premium_plugin_active( $plugin_id = false ) { if ( $plugin_id != $this->_fs->get_id() ) { return $this->_fs->is_addon_activated( $plugin_id, true ); } return is_plugin_active( $this->_fs->premium_plugin_basename() ); }
[ "private", "function", "is_premium_plugin_active", "(", "$", "plugin_id", "=", "false", ")", "{", "if", "(", "$", "plugin_id", "!=", "$", "this", "->", "_fs", "->", "get_id", "(", ")", ")", "{", "return", "$", "this", "->", "_fs", "->", "is_addon_activat...
Check if a premium module version is already active. @author Vova Feldman @since 1.2.1.7 @param number|bool $plugin_id @return bool
[ "Check", "if", "a", "premium", "module", "version", "is", "already", "active", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L1227-L1233
train
Freemius/wordpress-sdk
includes/class-fs-plugin-updater.php
FS_Plugin_Updater._store_basename_for_source_adjustment
static function _store_basename_for_source_adjustment( $response, $hook_extra ) { if ( isset( $hook_extra['plugin'] ) ) { self::$_upgrade_basename = $hook_extra['plugin']; } else if ( isset( $hook_extra['theme'] ) ) { self::$_upgrade_basename = $hook_extra['theme']; } else { self::$_upgrade_basename = null; } return $response; }
php
static function _store_basename_for_source_adjustment( $response, $hook_extra ) { if ( isset( $hook_extra['plugin'] ) ) { self::$_upgrade_basename = $hook_extra['plugin']; } else if ( isset( $hook_extra['theme'] ) ) { self::$_upgrade_basename = $hook_extra['theme']; } else { self::$_upgrade_basename = null; } return $response; }
[ "static", "function", "_store_basename_for_source_adjustment", "(", "$", "response", ",", "$", "hook_extra", ")", "{", "if", "(", "isset", "(", "$", "hook_extra", "[", "'plugin'", "]", ")", ")", "{", "self", "::", "$", "_upgrade_basename", "=", "$", "hook_ex...
Store the basename since it's not always available in the `_maybe_adjust_source_dir` method below. @author Leo Fajardo (@leorw) @since 2.2.1 @param bool|WP_Error $response Response. @param array $hook_extra Extra arguments passed to hooked filters. @return bool|WP_Error
[ "Store", "the", "basename", "since", "it", "s", "not", "always", "available", "in", "the", "_maybe_adjust_source_dir", "method", "below", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-fs-plugin-updater.php#L1246-L1256
train
Freemius/wordpress-sdk
includes/managers/class-fs-plan-manager.php
FS_Plan_Manager.has_paid_plan
function has_paid_plan( $plans ) { if ( ! is_array( $plans ) || 0 === count( $plans ) ) { return false; } /** * @var FS_Plugin_Plan[] $plans */ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { if ( ! $plans[ $i ]->is_free() ) { return true; } } return false; }
php
function has_paid_plan( $plans ) { if ( ! is_array( $plans ) || 0 === count( $plans ) ) { return false; } /** * @var FS_Plugin_Plan[] $plans */ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { if ( ! $plans[ $i ]->is_free() ) { return true; } } return false; }
[ "function", "has_paid_plan", "(", "$", "plans", ")", "{", "if", "(", "!", "is_array", "(", "$", "plans", ")", "||", "0", "===", "count", "(", "$", "plans", ")", ")", "{", "return", "false", ";", "}", "/**\n\t\t\t * @var FS_Plugin_Plan[] $plans\n\t\t\t */", ...
Check if plugin has any paid plans. @author Vova Feldman (@svovaf) @since 1.0.7 @param FS_Plugin_Plan[] $plans @return bool
[ "Check", "if", "plugin", "has", "any", "paid", "plans", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-plan-manager.php#L63-L78
train
Freemius/wordpress-sdk
includes/managers/class-fs-plan-manager.php
FS_Plan_Manager.get_trial_plans
function get_trial_plans( $plans ) { $trial_plans = array(); if ( is_array( $plans ) && 0 < count( $plans ) ) { /** * @var FS_Plugin_Plan[] $plans */ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { if ( $plans[ $i ]->has_trial() ) { $trial_plans[] = $plans[ $i ]; } } } return $trial_plans; }
php
function get_trial_plans( $plans ) { $trial_plans = array(); if ( is_array( $plans ) && 0 < count( $plans ) ) { /** * @var FS_Plugin_Plan[] $plans */ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { if ( $plans[ $i ]->has_trial() ) { $trial_plans[] = $plans[ $i ]; } } } return $trial_plans; }
[ "function", "get_trial_plans", "(", "$", "plans", ")", "{", "$", "trial_plans", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "plans", ")", "&&", "0", "<", "count", "(", "$", "plans", ")", ")", "{", "/**\n\t\t\t\t * @var FS_Plugin_Plan[] ...
Find all plans that have trial. @author Vova Feldman (@svovaf) @since 1.0.9 @param FS_Plugin_Plan[] $plans @return FS_Plugin_Plan[]
[ "Find", "all", "plans", "that", "have", "trial", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-plan-manager.php#L119-L134
train
Freemius/wordpress-sdk
includes/managers/class-fs-plan-manager.php
FS_Plan_Manager.has_trial_plan
function has_trial_plan( $plans ) { if ( ! is_array( $plans ) || 0 === count( $plans ) ) { return true; } /** * @var FS_Plugin_Plan[] $plans */ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { if ( $plans[ $i ]->has_trial() ) { return true; } } return false; }
php
function has_trial_plan( $plans ) { if ( ! is_array( $plans ) || 0 === count( $plans ) ) { return true; } /** * @var FS_Plugin_Plan[] $plans */ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { if ( $plans[ $i ]->has_trial() ) { return true; } } return false; }
[ "function", "has_trial_plan", "(", "$", "plans", ")", "{", "if", "(", "!", "is_array", "(", "$", "plans", ")", "||", "0", "===", "count", "(", "$", "plans", ")", ")", "{", "return", "true", ";", "}", "/**\n\t\t\t * @var FS_Plugin_Plan[] $plans\n\t\t\t */", ...
Check if plugin has any trial plan. @author Vova Feldman (@svovaf) @since 1.0.9 @param FS_Plugin_Plan[] $plans @return bool
[ "Check", "if", "plugin", "has", "any", "trial", "plan", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/managers/class-fs-plan-manager.php#L146-L161
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_settings_menu
function has_settings_menu() { return ( $this->_is_network_active && fs_is_network_admin() ) ? $this->_menu->has_network_menu() : $this->_menu->has_menu(); }
php
function has_settings_menu() { return ( $this->_is_network_active && fs_is_network_admin() ) ? $this->_menu->has_network_menu() : $this->_menu->has_menu(); }
[ "function", "has_settings_menu", "(", ")", "{", "return", "(", "$", "this", "->", "_is_network_active", "&&", "fs_is_network_admin", "(", ")", ")", "?", "$", "this", "->", "_menu", "->", "has_network_menu", "(", ")", ":", "$", "this", "->", "_menu", "->", ...
Checks whether this module has a settings menu. @author Leo Fajardo (@leorw) @since 1.2.2 @return bool
[ "Checks", "whether", "this", "module", "has", "a", "settings", "menu", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L504-L508
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_submenu_item_visible
function is_submenu_item_visible( $slug, $ignore_free_wp_org_theme_context = false ) { if ( $this->is_admin_page( $slug ) ) { /** * It is the current context page, so show the submenu item * so the user will have the right context page, even if it * was set to hidden. */ return true; } if ( ! $this->has_settings_menu() ) { // No menu settings at all. return false; } if ( ! $ignore_free_wp_org_theme_context && $this->is_free_wp_org_theme() ) { /** * wp.org themes are limited to a single submenu item, and * sub-submenu items are most likely not allowed (never verified). */ return false; } return $this->_menu->is_submenu_item_visible( $slug ); }
php
function is_submenu_item_visible( $slug, $ignore_free_wp_org_theme_context = false ) { if ( $this->is_admin_page( $slug ) ) { /** * It is the current context page, so show the submenu item * so the user will have the right context page, even if it * was set to hidden. */ return true; } if ( ! $this->has_settings_menu() ) { // No menu settings at all. return false; } if ( ! $ignore_free_wp_org_theme_context && $this->is_free_wp_org_theme() ) { /** * wp.org themes are limited to a single submenu item, and * sub-submenu items are most likely not allowed (never verified). */ return false; } return $this->_menu->is_submenu_item_visible( $slug ); }
[ "function", "is_submenu_item_visible", "(", "$", "slug", ",", "$", "ignore_free_wp_org_theme_context", "=", "false", ")", "{", "if", "(", "$", "this", "->", "is_admin_page", "(", "$", "slug", ")", ")", "{", "/**\r\n * It is the current context page, so...
Checks whether this a submenu item is visible. @author Vova Feldman (@svovaf) @since 1.2.2.6 @since 1.2.2.7 Even if the menu item was specified to be hidden, when it is the context page, then show the submenu item so the user will have the right context page. @param string $slug @param bool $ignore_free_wp_org_theme_context This is used to decide if the associated tab should be shown or hidden. @return bool
[ "Checks", "whether", "this", "a", "submenu", "item", "is", "visible", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L547-L571
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_page_visible
function is_page_visible( $slug ) { if ( $this->is_admin_page( $slug ) ) { return true; } return $this->_menu->is_submenu_item_visible( $slug, true, true ); }
php
function is_page_visible( $slug ) { if ( $this->is_admin_page( $slug ) ) { return true; } return $this->_menu->is_submenu_item_visible( $slug, true, true ); }
[ "function", "is_page_visible", "(", "$", "slug", ")", "{", "if", "(", "$", "this", "->", "is_admin_page", "(", "$", "slug", ")", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "_menu", "->", "is_submenu_item_visible", "(", "$", "slu...
Check if a Freemius page should be accessible via the UI. @author Vova Feldman (@svovaf) @since 1.2.2.7 @param string $slug @return bool
[ "Check", "if", "a", "Freemius", "page", "should", "be", "accessible", "via", "the", "UI", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L583-L589
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.remove_invalid_paths
private function remove_invalid_paths() { // Remove invalid path that is still associated with the current slug if there's any. $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() ); foreach ( $file_slug_map as $plugin_basename => $slug ) { if ( $slug === $this->_slug && $plugin_basename !== $this->_plugin_basename && ! file_exists( $this->get_absolute_path( $plugin_basename ) ) ) { unset( $file_slug_map[ $plugin_basename ] ); self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true ); break; } } }
php
private function remove_invalid_paths() { // Remove invalid path that is still associated with the current slug if there's any. $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() ); foreach ( $file_slug_map as $plugin_basename => $slug ) { if ( $slug === $this->_slug && $plugin_basename !== $this->_plugin_basename && ! file_exists( $this->get_absolute_path( $plugin_basename ) ) ) { unset( $file_slug_map[ $plugin_basename ] ); self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true ); break; } } }
[ "private", "function", "remove_invalid_paths", "(", ")", "{", "// Remove invalid path that is still associated with the current slug if there's any.\r", "$", "file_slug_map", "=", "self", "::", "$", "_accounts", "->", "get_option", "(", "'file_slug_map'", ",", "array", "(", ...
Remove invalid paths. @author Leo Fajardo (@leorw) @since 1.2.3
[ "Remove", "invalid", "paths", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L858-L872
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._plugins_loaded
function _plugins_loaded() { // Update flag that plugin was loaded with Freemius at least once. $this->_storage->was_plugin_loaded = true; /** * Bug fix - only set to false when it's a plugin, due to the * execution sequence of the theme hooks and our methods, if * this will be set for themes, Freemius will always assume * it's a theme update. * * @author Vova Feldman (@svovaf) * @since 1.2.2.2 */ if ( $this->is_plugin() && ! isset( $this->_storage->is_plugin_new_install ) ) { $this->_storage->is_plugin_new_install = false; } }
php
function _plugins_loaded() { // Update flag that plugin was loaded with Freemius at least once. $this->_storage->was_plugin_loaded = true; /** * Bug fix - only set to false when it's a plugin, due to the * execution sequence of the theme hooks and our methods, if * this will be set for themes, Freemius will always assume * it's a theme update. * * @author Vova Feldman (@svovaf) * @since 1.2.2.2 */ if ( $this->is_plugin() && ! isset( $this->_storage->is_plugin_new_install ) ) { $this->_storage->is_plugin_new_install = false; } }
[ "function", "_plugins_loaded", "(", ")", "{", "// Update flag that plugin was loaded with Freemius at least once.\r", "$", "this", "->", "_storage", "->", "was_plugin_loaded", "=", "true", ";", "/**\r\n * Bug fix - only set to false when it's a plugin, due to the\r\n ...
This action is connected to the 'plugins_loaded' hook and helps to determine if this is a new plugin installation or a plugin update. There are 3 different use-cases: 1) New plugin installation right with Freemius: 1.1 _activate_plugin_event_hook() will be executed first 1.2 Since $this->_storage->is_plugin_new_install is not set, and $this->_storage->plugin_last_version is not set, $this->_storage->is_plugin_new_install will be set to TRUE. 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will be already set to TRUE. 2) Plugin update, didn't have Freemius before, and now have the SDK: 2.1 _activate_plugin_event_hook() will not be executed, because the activation hook do NOT fires on updates since WP 3.1. 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will be empty, therefore, it will be set to FALSE. 3) Plugin update, had Freemius in prev version as well: 3.1 _version_updates_handler() will be executed 1st, since FS was installed before, $this->_storage->plugin_last_version will NOT be empty, therefore, $this->_storage->is_plugin_new_install will be set to FALSE. 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is already set, therefore, it will not be modified. Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9. NOTE: The only fallback of this mechanism is if an admin updates a plugin based on use-case #2, and then, the next immediate PageView is the plugin's main settings page, it will not show the opt-in right away. The reason it will happen is because Freemius execution will be turned off till the plugin is fully loaded at least once (till $this->_storage->was_plugin_loaded is TRUE). @author Vova Feldman (@svovaf) @since 1.1.9
[ "This", "action", "is", "connected", "to", "the", "plugins_loaded", "hook", "and", "helps", "to", "determine", "if", "this", "is", "a", "new", "plugin", "installation", "or", "a", "plugin", "update", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L1187-L1205
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._prepend_fs_allow_updater_and_dialog_flag_url_param
static function _prepend_fs_allow_updater_and_dialog_flag_url_param() { $slug_basename_map = array(); foreach ( self::$_instances as $instance ) { if ( ! $instance->is_plugin() ) { continue; } $slug_basename_map[ $instance->get_slug() ] = $instance->premium_plugin_basename(); } ?> <script type="text/javascript"> (function( $ ) { var slugBasenameMap = <?php echo json_encode( $slug_basename_map ) ?>; for ( var slug in slugBasenameMap ) { var basename = slugBasenameMap[ slug ]; // Try to get the plugin rows if on the "Plugins" page. var $pluginRows = $( '.wp-list-table.plugins tr[data-plugin="' + basename + '"]'); if ( 0 === $pluginRows.length ) { // Try to get the plugin rows if on the "Updates" page. var $pluginCheckbox = $( '#update-plugins-table input[type="checkbox"][value="' + basename + '"]' ); if ( 0 !== $pluginCheckbox.length ) { $pluginRows = $pluginCheckbox.parents( 'tr:first' ); } } if ( 0 === $pluginRows.length ) { // No plugin rows found. continue; } // Find the "View details" links and add the `fs_allow_updater_and_dialog` param to the URL. $pluginRows.find( 'a[href*="plugin-install.php?tab=plugin-information"]' ).each(function() { var $this = $( this ), href = $this.attr( 'href' ).replace( '?tab=', '?fs_allow_updater_and_dialog=true&tab='); $this.attr( 'href', href ); }); } })( jQuery ); </script> <?php }
php
static function _prepend_fs_allow_updater_and_dialog_flag_url_param() { $slug_basename_map = array(); foreach ( self::$_instances as $instance ) { if ( ! $instance->is_plugin() ) { continue; } $slug_basename_map[ $instance->get_slug() ] = $instance->premium_plugin_basename(); } ?> <script type="text/javascript"> (function( $ ) { var slugBasenameMap = <?php echo json_encode( $slug_basename_map ) ?>; for ( var slug in slugBasenameMap ) { var basename = slugBasenameMap[ slug ]; // Try to get the plugin rows if on the "Plugins" page. var $pluginRows = $( '.wp-list-table.plugins tr[data-plugin="' + basename + '"]'); if ( 0 === $pluginRows.length ) { // Try to get the plugin rows if on the "Updates" page. var $pluginCheckbox = $( '#update-plugins-table input[type="checkbox"][value="' + basename + '"]' ); if ( 0 !== $pluginCheckbox.length ) { $pluginRows = $pluginCheckbox.parents( 'tr:first' ); } } if ( 0 === $pluginRows.length ) { // No plugin rows found. continue; } // Find the "View details" links and add the `fs_allow_updater_and_dialog` param to the URL. $pluginRows.find( 'a[href*="plugin-install.php?tab=plugin-information"]' ).each(function() { var $this = $( this ), href = $this.attr( 'href' ).replace( '?tab=', '?fs_allow_updater_and_dialog=true&tab='); $this.attr( 'href', href ); }); } })( jQuery ); </script> <?php }
[ "static", "function", "_prepend_fs_allow_updater_and_dialog_flag_url_param", "(", ")", "{", "$", "slug_basename_map", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "_instances", "as", "$", "instance", ")", "{", "if", "(", "!", "$", "instance"...
Prepends the `fs_allow_updater_and_dialog` param to the plugin information URLs to tell the SDK to handle the information that is shown on the plugin details dialog that is shown when the relevant link is clicked. @author Leo Fajardo (@leorw) @since 2.2.3 @return string
[ "Prepends", "the", "fs_allow_updater_and_dialog", "param", "to", "the", "plugin", "information", "URLs", "to", "tell", "the", "SDK", "to", "handle", "the", "information", "that", "is", "shown", "on", "the", "plugin", "details", "dialog", "that", "is", "shown", ...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L1488-L1531
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.unregister_uninstall_hook
private function unregister_uninstall_hook() { $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); unset( $uninstallable_plugins[ $this->_free_plugin_basename ] ); unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] ); update_option( 'uninstall_plugins', $uninstallable_plugins ); }
php
private function unregister_uninstall_hook() { $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); unset( $uninstallable_plugins[ $this->_free_plugin_basename ] ); unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] ); update_option( 'uninstall_plugins', $uninstallable_plugins ); }
[ "private", "function", "unregister_uninstall_hook", "(", ")", "{", "$", "uninstallable_plugins", "=", "(", "array", ")", "get_option", "(", "'uninstall_plugins'", ")", ";", "unset", "(", "$", "uninstallable_plugins", "[", "$", "this", "->", "_free_plugin_basename", ...
Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a plugin will trigger inclusion of the free or premium version and if one of them is active during the uninstallation, a fatal error may occur in case the plugin's class or functions are already defined. @author Leo Fajardo (@leorw) @since 1.2.0
[ "Keeping", "the", "uninstall", "hook", "registered", "for", "free", "or", "premium", "plugin", "version", "may", "result", "to", "a", "fatal", "error", "that", "could", "happen", "when", "a", "user", "tries", "to", "uninstall", "either", "version", "while", ...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L1543-L1549
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._find_caller_plugin_file
private function _find_caller_plugin_file( $is_init = false ) { // Try to load the cached value of the file path. if ( isset( $this->_storage->plugin_main_file ) ) { $plugin_main_file = $this->_storage->plugin_main_file; if ( isset( $plugin_main_file->path ) ) { $absolute_path = $this->get_absolute_path( $plugin_main_file->path ); if ( file_exists( $absolute_path ) ) { return $absolute_path; } } } /** * @since 1.2.1 * * `clear_module_main_file_cache()` is clearing the plugin's cached path on * deactivation. Therefore, if any plugin/theme was initiating `Freemius` * with that plugin's slug, it was overriding the empty plugin path with a wrong path. * * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path` * when the class instantiator isn't the module. */ if ( ! $is_init ) { // Fetch prev path cache. if ( isset( $this->_storage->plugin_main_file ) && isset( $this->_storage->plugin_main_file->prev_path ) ) { $absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path ); if ( file_exists( $absolute_path ) ) { return $absolute_path; } } wp_die( $this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) . " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";", $this->get_text_inline( 'Error', 'error' ), array( 'back_link' => true ) ); } /** * @since 1.2.1 * * Only the original instantiator that calls dynamic_init can modify the module's path. */ // Find caller module. $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() ); $this->_storage->plugin_main_file = (object) array( 'path' => $id_slug_type_path_map[ $this->_module_id ]['path'], ); return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] ); }
php
private function _find_caller_plugin_file( $is_init = false ) { // Try to load the cached value of the file path. if ( isset( $this->_storage->plugin_main_file ) ) { $plugin_main_file = $this->_storage->plugin_main_file; if ( isset( $plugin_main_file->path ) ) { $absolute_path = $this->get_absolute_path( $plugin_main_file->path ); if ( file_exists( $absolute_path ) ) { return $absolute_path; } } } /** * @since 1.2.1 * * `clear_module_main_file_cache()` is clearing the plugin's cached path on * deactivation. Therefore, if any plugin/theme was initiating `Freemius` * with that plugin's slug, it was overriding the empty plugin path with a wrong path. * * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path` * when the class instantiator isn't the module. */ if ( ! $is_init ) { // Fetch prev path cache. if ( isset( $this->_storage->plugin_main_file ) && isset( $this->_storage->plugin_main_file->prev_path ) ) { $absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path ); if ( file_exists( $absolute_path ) ) { return $absolute_path; } } wp_die( $this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) . " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";", $this->get_text_inline( 'Error', 'error' ), array( 'back_link' => true ) ); } /** * @since 1.2.1 * * Only the original instantiator that calls dynamic_init can modify the module's path. */ // Find caller module. $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() ); $this->_storage->plugin_main_file = (object) array( 'path' => $id_slug_type_path_map[ $this->_module_id ]['path'], ); return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] ); }
[ "private", "function", "_find_caller_plugin_file", "(", "$", "is_init", "=", "false", ")", "{", "// Try to load the cached value of the file path.\r", "if", "(", "isset", "(", "$", "this", "->", "_storage", "->", "plugin_main_file", ")", ")", "{", "$", "plugin_main_...
Leverage backtrace to find caller plugin file path. @author Vova Feldman (@svovaf) @since 1.0.6 @param bool $is_init Is initiation sequence. @return string
[ "Leverage", "backtrace", "to", "find", "caller", "plugin", "file", "path", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L1654-L1707
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._add_deactivation_feedback_dialog_box
function _add_deactivation_feedback_dialog_box() { /* Check the type of user: * 1. Long-term (long-term) * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term). * 3. Short-term (short-term) */ $is_long_term_user = true; // Check if the site is at least 2 days old. $time_installed = $this->_storage->install_timestamp; // Difference in seconds. $date_diff = time() - $time_installed; // Convert seconds to days. $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) ); if ( $date_diff_days < 2 ) { $is_long_term_user = false; } $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user ); if ( $is_long_term_user ) { $user_type = 'long-term'; } else { if ( ! $this->is_registered() && ! $this->is_anonymous() ) { $user_type = 'non-registered-and-non-anonymous-short-term'; } else { $user_type = 'short-term'; } } $uninstall_reasons = $this->_get_uninstall_reasons( $user_type ); // Load the HTML template for the deactivation feedback dialog box. $vars = array( 'reasons' => $uninstall_reasons, 'id' => $this->_module_id ); /** * @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin. */ fs_require_template( 'forms/deactivation/form.php', $vars ); }
php
function _add_deactivation_feedback_dialog_box() { /* Check the type of user: * 1. Long-term (long-term) * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term). * 3. Short-term (short-term) */ $is_long_term_user = true; // Check if the site is at least 2 days old. $time_installed = $this->_storage->install_timestamp; // Difference in seconds. $date_diff = time() - $time_installed; // Convert seconds to days. $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) ); if ( $date_diff_days < 2 ) { $is_long_term_user = false; } $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user ); if ( $is_long_term_user ) { $user_type = 'long-term'; } else { if ( ! $this->is_registered() && ! $this->is_anonymous() ) { $user_type = 'non-registered-and-non-anonymous-short-term'; } else { $user_type = 'short-term'; } } $uninstall_reasons = $this->_get_uninstall_reasons( $user_type ); // Load the HTML template for the deactivation feedback dialog box. $vars = array( 'reasons' => $uninstall_reasons, 'id' => $this->_module_id ); /** * @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin. */ fs_require_template( 'forms/deactivation/form.php', $vars ); }
[ "function", "_add_deactivation_feedback_dialog_box", "(", ")", "{", "/* Check the type of user:\r\n\t\t\t * 1. Long-term (long-term)\r\n\t\t\t * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).\r\n\t\t\t * 3. Short-term (short-term)\r\n\t\t\t */", "$", "is_...
Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins page. @author Vova Feldman (@svovaf) @author Leo Fajardo (@leorw) @since 1.1.2
[ "Displays", "a", "confirmation", "and", "feedback", "dialog", "box", "when", "the", "user", "clicks", "on", "the", "Deactivate", "link", "on", "the", "plugins", "page", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L1939-L1984
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._submit_uninstall_reason_action
function _submit_uninstall_reason_action() { $this->_logger->entrance(); $this->check_ajax_referer( 'submit_uninstall_reason' ); $reason_id = fs_request_get( 'reason_id' ); // Check if the given reason ID is an unsigned integer. if ( ! ctype_digit( $reason_id ) ) { exit; } $reason_info = trim( fs_request_get( 'reason_info', '' ) ); if ( ! empty( $reason_info ) ) { $reason_info = substr( $reason_info, 0, 128 ); } $reason = (object) array( 'id' => $reason_id, 'info' => $reason_info, 'is_anonymous' => fs_request_get_bool( 'is_anonymous' ) ); $this->_storage->store( 'uninstall_reason', $reason ); /** * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do * not support uninstall hook. * * @author Leo Fajardo (@leorw) * @since 1.2.2 */ if ( $this->is_theme() ) { if ( $this->is_premium() && ! $this->has_active_valid_license() ) { FS_Plugin_Updater::instance( $this )->delete_update_data(); } $this->_uninstall_plugin_event( false ); $this->remove_sdk_reference(); } // Print '1' for successful operation. echo 1; exit; }
php
function _submit_uninstall_reason_action() { $this->_logger->entrance(); $this->check_ajax_referer( 'submit_uninstall_reason' ); $reason_id = fs_request_get( 'reason_id' ); // Check if the given reason ID is an unsigned integer. if ( ! ctype_digit( $reason_id ) ) { exit; } $reason_info = trim( fs_request_get( 'reason_info', '' ) ); if ( ! empty( $reason_info ) ) { $reason_info = substr( $reason_info, 0, 128 ); } $reason = (object) array( 'id' => $reason_id, 'info' => $reason_info, 'is_anonymous' => fs_request_get_bool( 'is_anonymous' ) ); $this->_storage->store( 'uninstall_reason', $reason ); /** * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do * not support uninstall hook. * * @author Leo Fajardo (@leorw) * @since 1.2.2 */ if ( $this->is_theme() ) { if ( $this->is_premium() && ! $this->has_active_valid_license() ) { FS_Plugin_Updater::instance( $this )->delete_update_data(); } $this->_uninstall_plugin_event( false ); $this->remove_sdk_reference(); } // Print '1' for successful operation. echo 1; exit; }
[ "function", "_submit_uninstall_reason_action", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "check_ajax_referer", "(", "'submit_uninstall_reason'", ")", ";", "$", "reason_id", "=", "fs_request_get", "(", "'reas...
Called after the user has submitted his reason for deactivating the plugin. @author Leo Fajardo (@leorw) @since 1.1.2
[ "Called", "after", "the", "user", "has", "submitted", "his", "reason", "for", "deactivating", "the", "plugin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2159-L2203
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.instance
static function instance( $module_id, $slug = false, $is_init = false ) { if ( empty( $module_id ) ) { return false; } /** * Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation. */ self::_load_required_static(); if ( ! is_numeric( $module_id ) ) { if ( ! $is_init && true === $slug ) { $is_init = true; } $slug = $module_id; $module = FS_Plugin_Manager::instance( $slug )->get(); if ( is_object( $module ) ) { $module_id = $module->id; } } $key = 'm_' . $module_id; if ( ! isset( self::$_instances[ $key ] ) ) { self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init ); } return self::$_instances[ $key ]; }
php
static function instance( $module_id, $slug = false, $is_init = false ) { if ( empty( $module_id ) ) { return false; } /** * Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation. */ self::_load_required_static(); if ( ! is_numeric( $module_id ) ) { if ( ! $is_init && true === $slug ) { $is_init = true; } $slug = $module_id; $module = FS_Plugin_Manager::instance( $slug )->get(); if ( is_object( $module ) ) { $module_id = $module->id; } } $key = 'm_' . $module_id; if ( ! isset( self::$_instances[ $key ] ) ) { self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init ); } return self::$_instances[ $key ]; }
[ "static", "function", "instance", "(", "$", "module_id", ",", "$", "slug", "=", "false", ",", "$", "is_init", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "module_id", ")", ")", "{", "return", "false", ";", "}", "/**\r\n * Load the e...
Main singleton instance. @author Vova Feldman (@svovaf) @since 1.0.0 @param number $module_id @param string|bool $slug @param bool $is_init Is initiation sequence. @return Freemius|false
[ "Main", "singleton", "instance", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2276-L2307
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_network_activation_mode
private function is_network_activation_mode( $and_on = true ) { if ( ! $this->_is_network_active ) { // Not network activated. return false; } if ( $this->is_network_upgrade_mode() ) { // Special flag to enforce network activation mode to decide what to do with the sites that are not yet opted-in nor skipped. return true; } if ( ! $this->is_site_activation_mode( $and_on ) ) { // Whether the context is single site or the network, if the plugin is no longer in activation mode then it is not in network activation mode as well. return false; } if ( $this->is_network_delegated_connection() ) { // Super-admin delegated the connection to the site admins -> not activation mode. return false; } if ( $this->is_network_anonymous() && true !== $this->_storage->require_license_activation ) { // Super-admin skipped the connection network wide -> not activation mode. return false; } if ( $this->is_network_registered() ) { // Super-admin connected at least one site -> not activation mode. return false; } return true; }
php
private function is_network_activation_mode( $and_on = true ) { if ( ! $this->_is_network_active ) { // Not network activated. return false; } if ( $this->is_network_upgrade_mode() ) { // Special flag to enforce network activation mode to decide what to do with the sites that are not yet opted-in nor skipped. return true; } if ( ! $this->is_site_activation_mode( $and_on ) ) { // Whether the context is single site or the network, if the plugin is no longer in activation mode then it is not in network activation mode as well. return false; } if ( $this->is_network_delegated_connection() ) { // Super-admin delegated the connection to the site admins -> not activation mode. return false; } if ( $this->is_network_anonymous() && true !== $this->_storage->require_license_activation ) { // Super-admin skipped the connection network wide -> not activation mode. return false; } if ( $this->is_network_registered() ) { // Super-admin connected at least one site -> not activation mode. return false; } return true; }
[ "private", "function", "is_network_activation_mode", "(", "$", "and_on", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "// Not network activated.\r", "return", "false", ";", "}", "if", "(", "$", "this", "->", "is_n...
Checks if the SDK in network activation mode. @author Leo Fajardo (@leorw) @since 2.0.0 @param bool $and_on @return bool
[ "Checks", "if", "the", "SDK", "in", "network", "activation", "mode", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2507-L2539
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_active_plugins_basenames
private static function get_active_plugins_basenames( $blog_id = 0 ) { if ( is_multisite() && $blog_id > 0 ) { $active_basenames = get_blog_option( $blog_id, 'active_plugins' ); } else { $active_basenames = get_option( 'active_plugins' ); } if ( is_multisite() ) { $network_active_basenames = get_site_option( 'active_sitewide_plugins' ); if ( is_array( $network_active_basenames ) && ! empty( $network_active_basenames ) ) { $active_basenames = array_merge( $active_basenames, $network_active_basenames ); } } return $active_basenames; }
php
private static function get_active_plugins_basenames( $blog_id = 0 ) { if ( is_multisite() && $blog_id > 0 ) { $active_basenames = get_blog_option( $blog_id, 'active_plugins' ); } else { $active_basenames = get_option( 'active_plugins' ); } if ( is_multisite() ) { $network_active_basenames = get_site_option( 'active_sitewide_plugins' ); if ( is_array( $network_active_basenames ) && ! empty( $network_active_basenames ) ) { $active_basenames = array_merge( $active_basenames, $network_active_basenames ); } } return $active_basenames; }
[ "private", "static", "function", "get_active_plugins_basenames", "(", "$", "blog_id", "=", "0", ")", "{", "if", "(", "is_multisite", "(", ")", "&&", "$", "blog_id", ">", "0", ")", "{", "$", "active_basenames", "=", "get_blog_option", "(", "$", "blog_id", "...
Get the basenames of all active plugins for specific blog. Including network activated plugins. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id @return string[]
[ "Get", "the", "basenames", "of", "all", "active", "plugins", "for", "specific", "blog", ".", "Including", "network", "activated", "plugins", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2617-L2633
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_active_plugins
private static function get_active_plugins( $blog_id = 0 ) { self::require_plugin_essentials(); $active_plugin = array(); $all_plugins = fs_get_plugins(); $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id ); foreach ( $active_plugins_basenames as $plugin_basename ) { $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ]; } return $active_plugin; }
php
private static function get_active_plugins( $blog_id = 0 ) { self::require_plugin_essentials(); $active_plugin = array(); $all_plugins = fs_get_plugins(); $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id ); foreach ( $active_plugins_basenames as $plugin_basename ) { $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ]; } return $active_plugin; }
[ "private", "static", "function", "get_active_plugins", "(", "$", "blog_id", "=", "0", ")", "{", "self", "::", "require_plugin_essentials", "(", ")", ";", "$", "active_plugin", "=", "array", "(", ")", ";", "$", "all_plugins", "=", "fs_get_plugins", "(", ")", ...
Get collection of all active plugins. Including network activated plugins. @author Vova Feldman (@svovaf) @since 1.0.9 @param int $blog_id Since 2.0.0 @return array[string]array
[ "Get", "collection", "of", "all", "active", "plugins", ".", "Including", "network", "activated", "plugins", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2645-L2657
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_site_active_plugins
private static function get_site_active_plugins( $blog_id = 0 ) { $active_basenames = ( is_multisite() && $blog_id > 0 ) ? get_blog_option( $blog_id, 'active_plugins' ) : get_option( 'active_plugins' ); $active = array(); if ( ! is_array( $active_basenames ) ) { return $active; } foreach ( $active_basenames as $basename ) { $active[ $basename ] = array( 'is_active' => true, 'Version' => '1.0', // Dummy version. 'slug' => self::get_plugin_slug( $basename ), ); } return $active; }
php
private static function get_site_active_plugins( $blog_id = 0 ) { $active_basenames = ( is_multisite() && $blog_id > 0 ) ? get_blog_option( $blog_id, 'active_plugins' ) : get_option( 'active_plugins' ); $active = array(); if ( ! is_array( $active_basenames ) ) { return $active; } foreach ( $active_basenames as $basename ) { $active[ $basename ] = array( 'is_active' => true, 'Version' => '1.0', // Dummy version. 'slug' => self::get_plugin_slug( $basename ), ); } return $active; }
[ "private", "static", "function", "get_site_active_plugins", "(", "$", "blog_id", "=", "0", ")", "{", "$", "active_basenames", "=", "(", "is_multisite", "(", ")", "&&", "$", "blog_id", ">", "0", ")", "?", "get_blog_option", "(", "$", "blog_id", ",", "'activ...
Get collection of all site active plugins for a specified blog. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id @return array[string]array
[ "Get", "collection", "of", "all", "site", "active", "plugins", "for", "a", "specified", "blog", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2669-L2689
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_all_plugins
private static function get_all_plugins( $blog_id = 0 ) { self::require_plugin_essentials(); $all_plugins = fs_get_plugins(); $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id ); foreach ( $all_plugins as $basename => &$data ) { // By default set to inactive (next foreach update the active plugins). $data['is_active'] = false; // Enrich with plugin slug. $data['slug'] = self::get_plugin_slug( $basename ); } // Flag active plugins. foreach ( $active_plugins_basenames as $basename ) { if ( isset( $all_plugins[ $basename ] ) ) { $all_plugins[ $basename ]['is_active'] = true; } } return $all_plugins; }
php
private static function get_all_plugins( $blog_id = 0 ) { self::require_plugin_essentials(); $all_plugins = fs_get_plugins(); $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id ); foreach ( $all_plugins as $basename => &$data ) { // By default set to inactive (next foreach update the active plugins). $data['is_active'] = false; // Enrich with plugin slug. $data['slug'] = self::get_plugin_slug( $basename ); } // Flag active plugins. foreach ( $active_plugins_basenames as $basename ) { if ( isset( $all_plugins[ $basename ] ) ) { $all_plugins[ $basename ]['is_active'] = true; } } return $all_plugins; }
[ "private", "static", "function", "get_all_plugins", "(", "$", "blog_id", "=", "0", ")", "{", "self", "::", "require_plugin_essentials", "(", ")", ";", "$", "all_plugins", "=", "fs_get_plugins", "(", ")", ";", "$", "active_plugins_basenames", "=", "self", "::",...
Get collection of all plugins with their activation status for a specified blog. @author Vova Feldman (@svovaf) @since 1.1.8 @param int $blog_id Since 2.0.0 @return array Key is the plugin file path and the value is an array of the plugin data.
[ "Get", "collection", "of", "all", "plugins", "with", "their", "activation", "status", "for", "a", "specified", "blog", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2701-L2723
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_network_plugins
private static function get_network_plugins() { self::require_plugin_essentials(); $all_plugins = fs_get_plugins(); $network_active_basenames = is_multisite() ? get_site_option( 'active_sitewide_plugins' ) : array(); foreach ( $all_plugins as $basename => &$data ) { // By default set to inactive (next foreach update the active plugins). $data['is_active'] = false; // Enrich with plugin slug. $data['slug'] = self::get_plugin_slug( $basename ); } // Flag active plugins. foreach ( $network_active_basenames as $basename ) { if ( isset( $all_plugins[ $basename ] ) ) { $all_plugins[ $basename ]['is_active'] = true; } } return $all_plugins; }
php
private static function get_network_plugins() { self::require_plugin_essentials(); $all_plugins = fs_get_plugins(); $network_active_basenames = is_multisite() ? get_site_option( 'active_sitewide_plugins' ) : array(); foreach ( $all_plugins as $basename => &$data ) { // By default set to inactive (next foreach update the active plugins). $data['is_active'] = false; // Enrich with plugin slug. $data['slug'] = self::get_plugin_slug( $basename ); } // Flag active plugins. foreach ( $network_active_basenames as $basename ) { if ( isset( $all_plugins[ $basename ] ) ) { $all_plugins[ $basename ]['is_active'] = true; } } return $all_plugins; }
[ "private", "static", "function", "get_network_plugins", "(", ")", "{", "self", "::", "require_plugin_essentials", "(", ")", ";", "$", "all_plugins", "=", "fs_get_plugins", "(", ")", ";", "$", "network_active_basenames", "=", "is_multisite", "(", ")", "?", "get_s...
Get collection of all plugins and if they are network level activated. @author Vova Feldman (@svovaf) @since 2.0.0 @return array Key is the plugin basename and the value is an array of the plugin data.
[ "Get", "collection", "of", "all", "plugins", "and", "if", "they", "are", "network", "level", "activated", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2733-L2757
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_plugin_slug
private static function get_plugin_slug( $basename ) { if ( ! isset( self::$_plugins_info ) ) { self::$_plugins_info = get_site_transient( 'update_plugins' ); } $slug = ''; if ( is_object( self::$_plugins_info ) ) { if ( isset( self::$_plugins_info->no_update ) && isset( self::$_plugins_info->no_update[ $basename ] ) && ! empty( self::$_plugins_info->no_update[ $basename ]->slug ) ) { $slug = self::$_plugins_info->no_update[ $basename ]->slug; } else if ( isset( self::$_plugins_info->response ) && isset( self::$_plugins_info->response[ $basename ] ) && ! empty( self::$_plugins_info->response[ $basename ]->slug ) ) { $slug = self::$_plugins_info->response[ $basename ]->slug; } } if ( empty( $slug ) ) { // Try to find slug from FS data. $slug = self::find_slug_by_basename( $basename ); } if ( empty( $slug ) ) { // Fallback to plugin's folder name. $slug = dirname( $basename ); } return $slug; }
php
private static function get_plugin_slug( $basename ) { if ( ! isset( self::$_plugins_info ) ) { self::$_plugins_info = get_site_transient( 'update_plugins' ); } $slug = ''; if ( is_object( self::$_plugins_info ) ) { if ( isset( self::$_plugins_info->no_update ) && isset( self::$_plugins_info->no_update[ $basename ] ) && ! empty( self::$_plugins_info->no_update[ $basename ]->slug ) ) { $slug = self::$_plugins_info->no_update[ $basename ]->slug; } else if ( isset( self::$_plugins_info->response ) && isset( self::$_plugins_info->response[ $basename ] ) && ! empty( self::$_plugins_info->response[ $basename ]->slug ) ) { $slug = self::$_plugins_info->response[ $basename ]->slug; } } if ( empty( $slug ) ) { // Try to find slug from FS data. $slug = self::find_slug_by_basename( $basename ); } if ( empty( $slug ) ) { // Fallback to plugin's folder name. $slug = dirname( $basename ); } return $slug; }
[ "private", "static", "function", "get_plugin_slug", "(", "$", "basename", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_plugins_info", ")", ")", "{", "self", "::", "$", "_plugins_info", "=", "get_site_transient", "(", "'update_plugins'", ")", ...
Helper function to get specified plugin's slug. @author Vova Feldman (@svovaf) @since 1.1.8 @param $basename @return string
[ "Helper", "function", "to", "get", "specified", "plugin", "s", "slug", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2779-L2811
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._load_required_static
private static function _load_required_static() { if ( self::$_statics_loaded ) { return; } self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK ); self::$_static_logger->entrance(); self::$_accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true ); if ( is_multisite() ) { $has_skipped_migration = ( // 'id_slug_type_path_map' - was never stored on older versions, therefore, not exists on the site level. null === self::$_accounts->get_option( 'id_slug_type_path_map', null, false ) && // 'file_slug_map' stored on the site level, so it was running an SDK version before it was integrated with MS-network. null !== self::$_accounts->get_option( 'file_slug_map', null, false ) ); /** * If the file_slug_map exists on the site level but doesn't exist on the * network level storage, it means that we need to process the storage with migration. * * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, file_slug_map will be already set in the network level storage. * * @author Vova Feldman (@svovaf) * @since 2.0.0 */ if ( ( $has_skipped_migration && true !== self::$_accounts->get_option( 'ms_migration_complete', false, true ) ) || ( null === self::$_accounts->get_option( 'file_slug_map', null, true ) && null !== self::$_accounts->get_option( 'file_slug_map', null, false ) ) ) { self::migrate_options_to_network(); } } self::$_global_admin_notices = FS_Admin_Notices::instance( 'global' ); if ( ! WP_FS__DEMO_MODE ) { add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array( 'Freemius', '_add_debug_section' ) ); } add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) ); self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) ); self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) ); self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) ); if ( 0 == did_action( 'plugins_loaded' ) ) { add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 ); } add_action( 'admin_footer', array( 'Freemius', '_enrich_ajax_url' ) ); add_action( 'admin_footer', array( 'Freemius', '_open_support_forum_in_new_page' ) ); self::$_statics_loaded = true; }
php
private static function _load_required_static() { if ( self::$_statics_loaded ) { return; } self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK ); self::$_static_logger->entrance(); self::$_accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true ); if ( is_multisite() ) { $has_skipped_migration = ( // 'id_slug_type_path_map' - was never stored on older versions, therefore, not exists on the site level. null === self::$_accounts->get_option( 'id_slug_type_path_map', null, false ) && // 'file_slug_map' stored on the site level, so it was running an SDK version before it was integrated with MS-network. null !== self::$_accounts->get_option( 'file_slug_map', null, false ) ); /** * If the file_slug_map exists on the site level but doesn't exist on the * network level storage, it means that we need to process the storage with migration. * * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, file_slug_map will be already set in the network level storage. * * @author Vova Feldman (@svovaf) * @since 2.0.0 */ if ( ( $has_skipped_migration && true !== self::$_accounts->get_option( 'ms_migration_complete', false, true ) ) || ( null === self::$_accounts->get_option( 'file_slug_map', null, true ) && null !== self::$_accounts->get_option( 'file_slug_map', null, false ) ) ) { self::migrate_options_to_network(); } } self::$_global_admin_notices = FS_Admin_Notices::instance( 'global' ); if ( ! WP_FS__DEMO_MODE ) { add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array( 'Freemius', '_add_debug_section' ) ); } add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) ); self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) ); self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) ); self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) ); if ( 0 == did_action( 'plugins_loaded' ) ) { add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 ); } add_action( 'admin_footer', array( 'Freemius', '_enrich_ajax_url' ) ); add_action( 'admin_footer', array( 'Freemius', '_open_support_forum_in_new_page' ) ); self::$_statics_loaded = true; }
[ "private", "static", "function", "_load_required_static", "(", ")", "{", "if", "(", "self", "::", "$", "_statics_loaded", ")", "{", "return", ";", "}", "self", "::", "$", "_static_logger", "=", "FS_Logger", "::", "get_logger", "(", "WP_FS__SLUG", ",", "WP_FS...
Load static resources. @author Vova Feldman (@svovaf) @since 1.0.1
[ "Load", "static", "resources", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L2821-L2884
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_on
function is_on() { self::$_static_logger->entrance(); if ( isset( $this->_is_on ) ) { return $this->_is_on; } // If already installed or pending then sure it's on :) if ( $this->is_registered() || $this->is_pending_activation() ) { $this->_is_on = true; return true; } return false; }
php
function is_on() { self::$_static_logger->entrance(); if ( isset( $this->_is_on ) ) { return $this->_is_on; } // If already installed or pending then sure it's on :) if ( $this->is_registered() || $this->is_pending_activation() ) { $this->_is_on = true; return true; } return false; }
[ "function", "is_on", "(", ")", "{", "self", "::", "$", "_static_logger", "->", "entrance", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_is_on", ")", ")", "{", "return", "$", "this", "->", "_is_on", ";", "}", "// If already installed or ...
Check if Freemius should be turned on for the current plugin install. Note: $this->_is_on is updated in has_api_connectivity() @author Vova Feldman (@svovaf) @since 1.0.9 @return bool
[ "Check", "if", "Freemius", "should", "be", "turned", "on", "for", "the", "current", "plugin", "install", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L3236-L3251
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_api_connectivity
function has_api_connectivity( $flush_if_no_connectivity = false ) { $this->_logger->entrance(); if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) { return $this->_has_api_connection; } if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY && isset( $this->_storage->connectivity_test ) && true === $this->_storage->connectivity_test['is_connected'] ) { unset( $this->_storage->connectivity_test ); } if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) { $this->_has_api_connection = $this->_storage->connectivity_test['is_connected']; /** * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration. * * @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation. */ $this->_is_on = $this->_storage->connectivity_test['is_active'] || $this->is_premium() || ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF ); return $this->_has_api_connection; } $pong = $this->ping(); $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong ); if ( ! $is_connected ) { // API failure. $this->_add_connectivity_issue_message( $pong ); } if ( $is_connected ) { FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required ); } $this->store_connectivity_info( $pong, $is_connected ); return $this->_has_api_connection; }
php
function has_api_connectivity( $flush_if_no_connectivity = false ) { $this->_logger->entrance(); if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) { return $this->_has_api_connection; } if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY && isset( $this->_storage->connectivity_test ) && true === $this->_storage->connectivity_test['is_connected'] ) { unset( $this->_storage->connectivity_test ); } if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) { $this->_has_api_connection = $this->_storage->connectivity_test['is_connected']; /** * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration. * * @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation. */ $this->_is_on = $this->_storage->connectivity_test['is_active'] || $this->is_premium() || ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF ); return $this->_has_api_connection; } $pong = $this->ping(); $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong ); if ( ! $is_connected ) { // API failure. $this->_add_connectivity_issue_message( $pong ); } if ( $is_connected ) { FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required ); } $this->store_connectivity_info( $pong, $is_connected ); return $this->_has_api_connection; }
[ "function", "has_api_connectivity", "(", "$", "flush_if_no_connectivity", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_has_api_connection", ")", "&&", "(", "$", "this",...
Check if there's any connectivity issue to Freemius API. @author Vova Feldman (@svovaf) @since 1.0.9 @param bool $flush_if_no_connectivity @return bool
[ "Check", "if", "there", "s", "any", "connectivity", "issue", "to", "Freemius", "API", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L3352-L3395
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.turn_on
private function turn_on() { $this->_logger->entrance(); if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) { return false; } $updated_connectivity = $this->_storage->connectivity_test; $updated_connectivity['is_active'] = true; $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME; $this->_storage->connectivity_test = $updated_connectivity; $this->_is_on = true; return true; }
php
private function turn_on() { $this->_logger->entrance(); if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) { return false; } $updated_connectivity = $this->_storage->connectivity_test; $updated_connectivity['is_active'] = true; $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME; $this->_storage->connectivity_test = $updated_connectivity; $this->_is_on = true; return true; }
[ "private", "function", "turn_on", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "is_on", "(", ")", "||", "!", "isset", "(", "$", "this", "->", "_storage", "->", "connectivity_test", "[", ...
Force turning Freemius on. @author Vova Feldman (@svovaf) @since 1.1.8.1 @return bool TRUE if successfully turned on.
[ "Force", "turning", "Freemius", "on", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L3444-L3459
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.send_email
private function send_email( $to_address, $subject, $sections = array(), $headers = array() ) { $default_sections = $this->get_email_sections(); // Insert new sections or replace the default email sections. if ( is_array( $sections ) && ! empty( $sections ) ) { foreach ( $sections as $section_id => $custom_section ) { if ( ! isset( $default_sections[ $section_id ] ) ) { // If the section does not exist, add it. $default_sections[ $section_id ] = $custom_section; } else { // If the section already exists, override it. $current_section = $default_sections[ $section_id ]; // Replace the current section's title if a custom section title exists. if ( isset( $custom_section['title'] ) ) { $current_section['title'] = $custom_section['title']; } // Insert new rows under the current section or replace the default rows. if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) { foreach ( $custom_section['rows'] as $row_id => $row ) { $current_section['rows'][ $row_id ] = $row; } } $default_sections[ $section_id ] = $current_section; } } } $vars = array( 'sections' => $default_sections ); $message = fs_get_template( 'email.php', $vars ); // Set the type of email to HTML. $headers[] = 'Content-type: text/html; charset=UTF-8'; $header_string = implode( "\r\n", $headers ); return wp_mail( $to_address, $subject, $message, $header_string ); }
php
private function send_email( $to_address, $subject, $sections = array(), $headers = array() ) { $default_sections = $this->get_email_sections(); // Insert new sections or replace the default email sections. if ( is_array( $sections ) && ! empty( $sections ) ) { foreach ( $sections as $section_id => $custom_section ) { if ( ! isset( $default_sections[ $section_id ] ) ) { // If the section does not exist, add it. $default_sections[ $section_id ] = $custom_section; } else { // If the section already exists, override it. $current_section = $default_sections[ $section_id ]; // Replace the current section's title if a custom section title exists. if ( isset( $custom_section['title'] ) ) { $current_section['title'] = $custom_section['title']; } // Insert new rows under the current section or replace the default rows. if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) { foreach ( $custom_section['rows'] as $row_id => $row ) { $current_section['rows'][ $row_id ] = $row; } } $default_sections[ $section_id ] = $current_section; } } } $vars = array( 'sections' => $default_sections ); $message = fs_get_template( 'email.php', $vars ); // Set the type of email to HTML. $headers[] = 'Content-type: text/html; charset=UTF-8'; $header_string = implode( "\r\n", $headers ); return wp_mail( $to_address, $subject, $message, $header_string ); }
[ "private", "function", "send_email", "(", "$", "to_address", ",", "$", "subject", ",", "$", "sections", "=", "array", "(", ")", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "default_sections", "=", "$", "this", "->", "get_email_sections", ...
Generates and sends an HTML email with customizable sections. @author Leo Fajardo (@leorw) @since 1.1.2 @param string $to_address @param string $subject @param array $sections @param array $headers @return bool Whether the email contents were sent successfully.
[ "Generates", "and", "sends", "an", "HTML", "email", "with", "customizable", "sections", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L3994-L4043
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_email_sections
private function get_email_sections() { // Retrieve the current user's information so that we can get the user's email, first name, and last name below. $current_user = self::_get_current_wp_user(); // Retrieve the cURL version information so that we can get the version number below. $curl_version_information = curl_version(); $active_plugin = self::get_active_plugins(); // Generate the list of active plugins separated by new line. $active_plugin_string = ''; foreach ( $active_plugin as $plugin ) { $active_plugin_string .= sprintf( '<a href="%s">%s</a> [v%s]<br>', $plugin['PluginURI'], $plugin['Name'], $plugin['Version'] ); } $server_ip = WP_FS__REMOTE_ADDR; // Add PHP info for deeper investigation. ob_start(); phpinfo(); $php_info = ob_get_clean(); $api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 ); // Generate the default email sections. $sections = array( 'sdk' => array( 'title' => 'SDK', 'rows' => array( 'fs_version' => array( 'FS Version', $this->version ), 'curl_version' => array( 'cURL Version', $curl_version_information['version'] ) ) ), 'plugin' => array( 'title' => ucfirst( $this->get_module_type() ), 'rows' => array( 'name' => array( 'Name', $this->get_plugin_name() ), 'version' => array( 'Version', $this->get_plugin_version() ) ) ), 'api' => array( 'title' => 'API Subdomain', 'rows' => array( 'dns' => array( 'DNS_CNAME', function_exists( 'dns_get_record' ) ? var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) : 'dns_get_record() disabled/blocked' ), 'ip' => array( 'IP', function_exists( 'gethostbyname' ) ? gethostbyname( $api_domain ) : 'gethostbyname() disabled/blocked' ), ), ), 'site' => array( 'title' => 'Site', 'rows' => array( 'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ), 'address' => array( 'Address', site_url() ), 'host' => array( 'HTTP_HOST', ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' ) ), 'hosting' => array( 'Hosting Company' => fs_request_has( 'hosting_company' ) ? fs_request_get( 'hosting_company' ) : 'Unknown', ), 'server_addr' => array( 'SERVER_ADDR', '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>' ) ) ), 'user' => array( 'title' => 'User', 'rows' => array( 'email' => array( 'Email', $current_user->user_email ), 'first' => array( 'First', $current_user->user_firstname ), 'last' => array( 'Last', $current_user->user_lastname ) ) ), 'plugins' => array( 'title' => 'Plugins', 'rows' => array( 'active_plugins' => array( 'Active Plugins', $active_plugin_string ) ) ), 'php_info' => array( 'title' => 'PHP Info', 'rows' => array( 'info' => array( $php_info ) ), ) ); // Allow the sections to be modified by other code. $sections = $this->apply_filters( 'email_template_sections', $sections ); return $sections; }
php
private function get_email_sections() { // Retrieve the current user's information so that we can get the user's email, first name, and last name below. $current_user = self::_get_current_wp_user(); // Retrieve the cURL version information so that we can get the version number below. $curl_version_information = curl_version(); $active_plugin = self::get_active_plugins(); // Generate the list of active plugins separated by new line. $active_plugin_string = ''; foreach ( $active_plugin as $plugin ) { $active_plugin_string .= sprintf( '<a href="%s">%s</a> [v%s]<br>', $plugin['PluginURI'], $plugin['Name'], $plugin['Version'] ); } $server_ip = WP_FS__REMOTE_ADDR; // Add PHP info for deeper investigation. ob_start(); phpinfo(); $php_info = ob_get_clean(); $api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 ); // Generate the default email sections. $sections = array( 'sdk' => array( 'title' => 'SDK', 'rows' => array( 'fs_version' => array( 'FS Version', $this->version ), 'curl_version' => array( 'cURL Version', $curl_version_information['version'] ) ) ), 'plugin' => array( 'title' => ucfirst( $this->get_module_type() ), 'rows' => array( 'name' => array( 'Name', $this->get_plugin_name() ), 'version' => array( 'Version', $this->get_plugin_version() ) ) ), 'api' => array( 'title' => 'API Subdomain', 'rows' => array( 'dns' => array( 'DNS_CNAME', function_exists( 'dns_get_record' ) ? var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) : 'dns_get_record() disabled/blocked' ), 'ip' => array( 'IP', function_exists( 'gethostbyname' ) ? gethostbyname( $api_domain ) : 'gethostbyname() disabled/blocked' ), ), ), 'site' => array( 'title' => 'Site', 'rows' => array( 'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ), 'address' => array( 'Address', site_url() ), 'host' => array( 'HTTP_HOST', ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' ) ), 'hosting' => array( 'Hosting Company' => fs_request_has( 'hosting_company' ) ? fs_request_get( 'hosting_company' ) : 'Unknown', ), 'server_addr' => array( 'SERVER_ADDR', '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>' ) ) ), 'user' => array( 'title' => 'User', 'rows' => array( 'email' => array( 'Email', $current_user->user_email ), 'first' => array( 'First', $current_user->user_firstname ), 'last' => array( 'Last', $current_user->user_lastname ) ) ), 'plugins' => array( 'title' => 'Plugins', 'rows' => array( 'active_plugins' => array( 'Active Plugins', $active_plugin_string ) ) ), 'php_info' => array( 'title' => 'PHP Info', 'rows' => array( 'info' => array( $php_info ) ), ) ); // Allow the sections to be modified by other code. $sections = $this->apply_filters( 'email_template_sections', $sections ); return $sections; }
[ "private", "function", "get_email_sections", "(", ")", "{", "// Retrieve the current user's information so that we can get the user's email, first name, and last name below.\r", "$", "current_user", "=", "self", "::", "_get_current_wp_user", "(", ")", ";", "// Retrieve the cURL versi...
Generates the data for the sections of the email content. @author Leo Fajardo (@leorw) @since 1.1.2 @return array
[ "Generates", "the", "data", "for", "the", "sections", "of", "the", "email", "content", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L4053-L4161
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.init
function init( $id, $public_key, $is_live = true, $is_premium = true ) { $this->_logger->entrance(); $this->dynamic_init( array( 'id' => $id, 'public_key' => $public_key, 'is_live' => $is_live, 'is_premium' => $is_premium, ) ); }
php
function init( $id, $public_key, $is_live = true, $is_premium = true ) { $this->_logger->entrance(); $this->dynamic_init( array( 'id' => $id, 'public_key' => $public_key, 'is_live' => $is_live, 'is_premium' => $is_premium, ) ); }
[ "function", "init", "(", "$", "id", ",", "$", "public_key", ",", "$", "is_live", "=", "true", ",", "$", "is_premium", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "dynamic_init", "(", "arr...
Init plugin's Freemius instance. @author Vova Feldman (@svovaf) @since 1.0.1 @param number $id @param string $public_key @param bool $is_live @param bool $is_premium
[ "Init", "plugin", "s", "Freemius", "instance", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L4180-L4189
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.stop_network_tracking
function stop_network_tracking() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { // User never opted-in. return false; } $install_id_2_blog_id = array(); $installs_map = $this->get_blog_install_map(); $opt_out_all = true; $params = array(); foreach ( $installs_map as $blog_id => $install ) { if ( $install->is_tracking_prohibited() ) { // Already opted-out. continue; } if ( $this->is_site_delegated_connection( $blog_id ) ) { // Opt-out only from non-delegated installs. $opt_out_all = false; continue; } $params[] = array( 'id' => $install->id ); $install_id_2_blog_id[ $install->id ] = $blog_id; } if ( empty( $install_id_2_blog_id ) ) { return true; } $params[] = array( 'is_disconnected' => true ); // Send update to FS. $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { $this->_logger->api_error( $result ); return $result; } foreach ( $result->installs as $r_install ) { $blog_id = $install_id_2_blog_id[ $r_install->id ]; $install = $installs_map[ $blog_id ]; $install->is_disconnected = $r_install->is_disconnected; $this->_store_site( true, $blog_id, $install ); } $this->clear_sync_cron( $opt_out_all ); // Successfully disconnected. return true; }
php
function stop_network_tracking() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { // User never opted-in. return false; } $install_id_2_blog_id = array(); $installs_map = $this->get_blog_install_map(); $opt_out_all = true; $params = array(); foreach ( $installs_map as $blog_id => $install ) { if ( $install->is_tracking_prohibited() ) { // Already opted-out. continue; } if ( $this->is_site_delegated_connection( $blog_id ) ) { // Opt-out only from non-delegated installs. $opt_out_all = false; continue; } $params[] = array( 'id' => $install->id ); $install_id_2_blog_id[ $install->id ] = $blog_id; } if ( empty( $install_id_2_blog_id ) ) { return true; } $params[] = array( 'is_disconnected' => true ); // Send update to FS. $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { $this->_logger->api_error( $result ); return $result; } foreach ( $result->installs as $r_install ) { $blog_id = $install_id_2_blog_id[ $r_install->id ]; $install = $installs_map[ $blog_id ]; $install->is_disconnected = $r_install->is_disconnected; $this->_store_site( true, $blog_id, $install ); } $this->clear_sync_cron( $opt_out_all ); // Successfully disconnected. return true; }
[ "function", "stop_network_tracking", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", ")", "{", "// User never opted-in.\r", "return", "false", ";", "}", "$", "ins...
Opt-out network from usage tracking. Note: This will not delete the account information but will stop all tracking. Returns: 1. FALSE - If the user never opted-in. 2. TRUE - If successfully opted-out. 3. object - API result on failure. @author Leo Fajardo (@leorw) @since 1.2.1.5 @return bool|object
[ "Opt", "-", "out", "network", "from", "usage", "tracking", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L4611-L4668
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.allow_network_tracking
function allow_network_tracking() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { // User never opted-in. return false; } $install_id_2_blog_id = array(); $installs_map = $this->get_blog_install_map(); $params = array(); foreach ( $installs_map as $blog_id => $install ) { if ( $install->is_tracking_allowed() ) { continue; } $params[] = array( 'id' => $install->id ); $install_id_2_blog_id[ $install->id ] = $blog_id; } if ( empty( $install_id_2_blog_id ) ) { return true; } $params[] = array( 'is_disconnected' => false ); // Send update to FS. $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { $this->_logger->api_error( $result ); return $result; } foreach ( $result->installs as $r_install ) { $blog_id = $install_id_2_blog_id[ $r_install->id ]; $install = $installs_map[ $blog_id ]; $install->is_disconnected = $r_install->is_disconnected; $this->_store_site( true, $blog_id, $install ); } $this->schedule_sync_cron(); // Successfully reconnected. return true; }
php
function allow_network_tracking() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { // User never opted-in. return false; } $install_id_2_blog_id = array(); $installs_map = $this->get_blog_install_map(); $params = array(); foreach ( $installs_map as $blog_id => $install ) { if ( $install->is_tracking_allowed() ) { continue; } $params[] = array( 'id' => $install->id ); $install_id_2_blog_id[ $install->id ] = $blog_id; } if ( empty( $install_id_2_blog_id ) ) { return true; } $params[] = array( 'is_disconnected' => false ); // Send update to FS. $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { $this->_logger->api_error( $result ); return $result; } foreach ( $result->installs as $r_install ) { $blog_id = $install_id_2_blog_id[ $r_install->id ]; $install = $installs_map[ $blog_id ]; $install->is_disconnected = $r_install->is_disconnected; $this->_store_site( true, $blog_id, $install ); } $this->schedule_sync_cron(); // Successfully reconnected. return true; }
[ "function", "allow_network_tracking", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", ")", "{", "// User never opted-in.\r", "return", "false", ";", "}", "$", "in...
Opt-in network back into usage tracking. Note: This will only work if the user opted-in previously. Returns: 1. FALSE - If the user never opted-in. 2. TRUE - If successfully opted-in back to usage tracking. 3. object - API result on failure. @author Leo Fajardo (@leorw) @since 1.2.1.5 @return bool|object
[ "Opt", "-", "in", "network", "back", "into", "usage", "tracking", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L4760-L4809
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.reconnect_locally
private function reconnect_locally( $is_context_single_site = false ) { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return; } if ( ! fs_is_network_admin() || $is_context_single_site ) { if ( $this->is_tracking_prohibited() ) { $this->_site->is_disconnected = false; $this->_store_site(); } } else { $installs_map = $this->get_blog_install_map(); foreach ( $installs_map as $blog_id => $install ) { /** * @var FS_Site $install */ if ( $install->is_tracking_prohibited() ) { $install->is_disconnected = false; $this->_store_site( true, $blog_id, $install ); } } } }
php
private function reconnect_locally( $is_context_single_site = false ) { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return; } if ( ! fs_is_network_admin() || $is_context_single_site ) { if ( $this->is_tracking_prohibited() ) { $this->_site->is_disconnected = false; $this->_store_site(); } } else { $installs_map = $this->get_blog_install_map(); foreach ( $installs_map as $blog_id => $install ) { /** * @var FS_Site $install */ if ( $install->is_tracking_prohibited() ) { $install->is_disconnected = false; $this->_store_site( true, $blog_id, $install ); } } } }
[ "private", "function", "reconnect_locally", "(", "$", "is_context_single_site", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", ")", "{", "return", ";", ...
If user opted-in and later disabled usage-tracking, re-allow tracking for licensing and updates. @author Leo Fajardo (@leorw) @since 1.2.1.5 @param bool $is_context_single_site
[ "If", "user", "opted", "-", "in", "and", "later", "disabled", "usage", "-", "tracking", "re", "-", "allow", "tracking", "for", "licensing", "and", "updates", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L4845-L4869
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.should_stop_execution
private function should_stop_execution() { if ( empty( $this->_storage->was_plugin_loaded ) ) { /** * Don't execute Freemius until plugin was fully loaded at least once, * to give the opportunity for the activation hook to run before pinging * the API for connectivity test. This logic is relevant for the * identification of new plugin install vs. plugin update. * * @author Vova Feldman (@svovaf) * @since 1.1.9 */ return true; } if ( $this->is_activation_mode() ) { if ( ! is_admin() ) { /** * If in activation mode, don't execute Freemius outside of the * admin dashboard. * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 */ return true; } if ( ! WP_FS__IS_HTTP_REQUEST ) { /** * If in activation and executed without HTTP context (e.g. CLI, Cronjob), * then don't start Freemius. * * @author Vova Feldman (@svovaf) * @since 1.1.6.3 * * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli */ return true; } if ( self::is_cron() ) { /** * If in activation mode, don't execute Freemius during wp crons * (wp crons have HTTP context - called as HTTP request). * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 */ return true; } if ( self::is_ajax() && ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) && ! $this->_admin_notices->has_sticky( 'failed_connect_api' ) ) { /** * During activation, if running in AJAX mode, unless there's a sticky * connectivity issue notice, don't run Freemius. * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 */ return true; } } return false; }
php
private function should_stop_execution() { if ( empty( $this->_storage->was_plugin_loaded ) ) { /** * Don't execute Freemius until plugin was fully loaded at least once, * to give the opportunity for the activation hook to run before pinging * the API for connectivity test. This logic is relevant for the * identification of new plugin install vs. plugin update. * * @author Vova Feldman (@svovaf) * @since 1.1.9 */ return true; } if ( $this->is_activation_mode() ) { if ( ! is_admin() ) { /** * If in activation mode, don't execute Freemius outside of the * admin dashboard. * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 */ return true; } if ( ! WP_FS__IS_HTTP_REQUEST ) { /** * If in activation and executed without HTTP context (e.g. CLI, Cronjob), * then don't start Freemius. * * @author Vova Feldman (@svovaf) * @since 1.1.6.3 * * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli */ return true; } if ( self::is_cron() ) { /** * If in activation mode, don't execute Freemius during wp crons * (wp crons have HTTP context - called as HTTP request). * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 */ return true; } if ( self::is_ajax() && ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) && ! $this->_admin_notices->has_sticky( 'failed_connect_api' ) ) { /** * During activation, if running in AJAX mode, unless there's a sticky * connectivity issue notice, don't run Freemius. * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 */ return true; } } return false; }
[ "private", "function", "should_stop_execution", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_storage", "->", "was_plugin_loaded", ")", ")", "{", "/**\r\n * Don't execute Freemius until plugin was fully loaded at least once,\r\n * ...
Gate keeper. @author Vova Feldman (@svovaf) @since 1.1.7.3 @return bool
[ "Gate", "keeper", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5031-L5097
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._after_code_type_change
function _after_code_type_change() { $this->_logger->entrance(); if ( $this->is_theme() ) { // Expire the cache of the previous tabs since the theme may // have setting updates after code type has changed. $this->_cache->expire( 'tabs' ); $this->_cache->expire( 'tabs_stylesheets' ); } if ( $this->is_registered() ) { if ( ! $this->is_addon() ) { add_action( is_admin() ? 'admin_init' : 'init', array( &$this, '_plugin_code_type_changed' ) ); } if ( $this->is_premium() ) { // Purge cached payments after switching to the premium version. // @todo This logic doesn't handle purging the cache for serviceware module upgrade. $this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" ); } } }
php
function _after_code_type_change() { $this->_logger->entrance(); if ( $this->is_theme() ) { // Expire the cache of the previous tabs since the theme may // have setting updates after code type has changed. $this->_cache->expire( 'tabs' ); $this->_cache->expire( 'tabs_stylesheets' ); } if ( $this->is_registered() ) { if ( ! $this->is_addon() ) { add_action( is_admin() ? 'admin_init' : 'init', array( &$this, '_plugin_code_type_changed' ) ); } if ( $this->is_premium() ) { // Purge cached payments after switching to the premium version. // @todo This logic doesn't handle purging the cache for serviceware module upgrade. $this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" ); } } }
[ "function", "_after_code_type_change", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "is_theme", "(", ")", ")", "{", "// Expire the cache of the previous tabs since the theme may\r", "// have setting upda...
Triggered after code type has changed. @author Vova Feldman (@svovaf) @since 1.1.9.1
[ "Triggered", "after", "code", "type", "has", "changed", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5105-L5129
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_addon_activated
function is_addon_activated( $id_or_slug, $is_premium = null ) { $this->_logger->entrance(); $addon_id = self::get_module_id( $id_or_slug ); $is_activated = self::has_instance( $addon_id ); if ( ! $is_activated ) { return false; } if ( is_bool( $is_premium ) ) { // Check if the specified code version is activate. $addon = $this->get_addon_instance( $addon_id ); $is_activated = ( $is_premium === $addon->is_premium() ); } return $is_activated; }
php
function is_addon_activated( $id_or_slug, $is_premium = null ) { $this->_logger->entrance(); $addon_id = self::get_module_id( $id_or_slug ); $is_activated = self::has_instance( $addon_id ); if ( ! $is_activated ) { return false; } if ( is_bool( $is_premium ) ) { // Check if the specified code version is activate. $addon = $this->get_addon_instance( $addon_id ); $is_activated = ( $is_premium === $addon->is_premium() ); } return $is_activated; }
[ "function", "is_addon_activated", "(", "$", "id_or_slug", ",", "$", "is_premium", "=", "null", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "addon_id", "=", "self", "::", "get_module_id", "(", "$", "id_or_slug", ")", ";",...
Check if add-on installed and activated on site. @author Vova Feldman (@svovaf) @since 1.0.6 @param string|number $id_or_slug @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version. @return bool
[ "Check", "if", "add", "-", "on", "installed", "and", "activated", "on", "site", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5229-L5246
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_addon_connected
function is_addon_connected( $id_or_slug ) { $this->_logger->entrance(); $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN ); $addon_id = self::get_module_id( $id_or_slug ); $addon = $this->get_addon( $addon_id ); $slug = $addon->slug; if ( ! isset( $sites[ $slug ] ) ) { return false; } $site = $sites[ $slug ]; $plugin = FS_Plugin_Manager::instance( $addon_id )->get(); if ( $plugin->parent_plugin_id != $this->_plugin->id ) { // The given slug do NOT belong to any of the plugin's add-ons. return false; } return ( is_object( $site ) && is_numeric( $site->id ) && is_numeric( $site->user_id ) && FS_Plugin_Plan::is_valid_id( $site->plan_id ) ); }
php
function is_addon_connected( $id_or_slug ) { $this->_logger->entrance(); $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN ); $addon_id = self::get_module_id( $id_or_slug ); $addon = $this->get_addon( $addon_id ); $slug = $addon->slug; if ( ! isset( $sites[ $slug ] ) ) { return false; } $site = $sites[ $slug ]; $plugin = FS_Plugin_Manager::instance( $addon_id )->get(); if ( $plugin->parent_plugin_id != $this->_plugin->id ) { // The given slug do NOT belong to any of the plugin's add-ons. return false; } return ( is_object( $site ) && is_numeric( $site->id ) && is_numeric( $site->user_id ) && FS_Plugin_Plan::is_valid_id( $site->plan_id ) ); }
[ "function", "is_addon_connected", "(", "$", "id_or_slug", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "sites", "=", "self", "::", "get_all_sites", "(", "WP_FS__MODULE_TYPE_PLUGIN", ")", ";", "$", "addon_id", "=", "self", "...
Check if add-on was connected to install @author Vova Feldman (@svovaf) @since 1.1.7 @param string|number $id_or_slug @return bool
[ "Check", "if", "add", "-", "on", "was", "connected", "to", "install" ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5258-L5284
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_addon_installed
function is_addon_installed( $id_or_slug ) { $this->_logger->entrance(); $addon_id = self::get_module_id( $id_or_slug ); return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) ); }
php
function is_addon_installed( $id_or_slug ) { $this->_logger->entrance(); $addon_id = self::get_module_id( $id_or_slug ); return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) ); }
[ "function", "is_addon_installed", "(", "$", "id_or_slug", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "addon_id", "=", "self", "::", "get_module_id", "(", "$", "id_or_slug", ")", ";", "return", "file_exists", "(", "fs_norm...
Determines if add-on installed. NOTE: This is a heuristic and only works if the folder/file named as the slug. @author Vova Feldman (@svovaf) @since 1.0.6 @param string|number $id_or_slug @return bool
[ "Determines", "if", "add", "-", "on", "installed", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5298-L5304
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_addon_basename
function get_addon_basename( $id_or_slug ) { $addon_id = self::get_module_id( $id_or_slug ); if ( $this->is_addon_activated( $addon_id ) ) { return self::instance( $addon_id )->get_plugin_basename(); } $addon = $this->get_addon( $addon_id ); $premium_basename = "{$addon->premium_slug}/{$addon->slug}.php"; if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) { return $premium_basename; } $all_plugins = $this->get_all_plugins(); foreach ( $all_plugins as $basename => $data ) { if ( $addon->slug === $data['slug'] || $addon->premium_slug === $data['slug'] ) { return $basename; } } $free_basename = "{$addon->slug}/{$addon->slug}.php"; return $free_basename; }
php
function get_addon_basename( $id_or_slug ) { $addon_id = self::get_module_id( $id_or_slug ); if ( $this->is_addon_activated( $addon_id ) ) { return self::instance( $addon_id )->get_plugin_basename(); } $addon = $this->get_addon( $addon_id ); $premium_basename = "{$addon->premium_slug}/{$addon->slug}.php"; if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) { return $premium_basename; } $all_plugins = $this->get_all_plugins(); foreach ( $all_plugins as $basename => $data ) { if ( $addon->slug === $data['slug'] || $addon->premium_slug === $data['slug'] ) { return $basename; } } $free_basename = "{$addon->slug}/{$addon->slug}.php"; return $free_basename; }
[ "function", "get_addon_basename", "(", "$", "id_or_slug", ")", "{", "$", "addon_id", "=", "self", "::", "get_module_id", "(", "$", "id_or_slug", ")", ";", "if", "(", "$", "this", "->", "is_addon_activated", "(", "$", "addon_id", ")", ")", "{", "return", ...
Get add-on basename. @author Vova Feldman (@svovaf) @since 1.0.6 @param string|number $id_or_slug @return string
[ "Get", "add", "-", "on", "basename", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5316-L5343
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_installed_addons
function get_installed_addons() { $installed_addons = array(); foreach ( self::$_instances as $instance ) { if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) { if ( $this->_plugin->id == $instance->_parent_plugin->id ) { $installed_addons[] = $instance; } } } return $installed_addons; }
php
function get_installed_addons() { $installed_addons = array(); foreach ( self::$_instances as $instance ) { if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) { if ( $this->_plugin->id == $instance->_parent_plugin->id ) { $installed_addons[] = $instance; } } } return $installed_addons; }
[ "function", "get_installed_addons", "(", ")", "{", "$", "installed_addons", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "_instances", "as", "$", "instance", ")", "{", "if", "(", "$", "instance", "->", "is_addon", "(", ")", "&&", "is...
Get installed add-ons instances. @author Vova Feldman (@svovaf) @since 1.0.6 @return Freemius[]
[ "Get", "installed", "add", "-", "ons", "instances", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5353-L5364
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_installed_addons
function has_installed_addons() { if ( ! $this->has_addons() ) { return false; } foreach ( self::$_instances as $instance ) { if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) { if ( $this->_plugin->id == $instance->_parent_plugin->id ) { return true; } } } return false; }
php
function has_installed_addons() { if ( ! $this->has_addons() ) { return false; } foreach ( self::$_instances as $instance ) { if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) { if ( $this->_plugin->id == $instance->_parent_plugin->id ) { return true; } } } return false; }
[ "function", "has_installed_addons", "(", ")", "{", "if", "(", "!", "$", "this", "->", "has_addons", "(", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "self", "::", "$", "_instances", "as", "$", "instance", ")", "{", "if", "(", "$", "...
Check if any add-ons of the plugin are installed. @author Leo Fajardo (@leorw) @since 1.1.1 @return bool
[ "Check", "if", "any", "add", "-", "ons", "of", "the", "plugin", "are", "installed", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5374-L5388
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.deactivate_premium_only_addon_without_license
private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) { if ( ! $this->has_free_plan() && ! $this->has_features_enabled_license() && ! $this->_has_premium_license() ) { if ( $this->is_registered() ) { // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons). // if (empty($this->_storage->activation_timestamp) || // (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30 // ) { /** * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation. * * Retry syncing the user add-on licenses. */ // Sync licenses. $this->_sync_licenses(); // } // Try to activate premium license. $this->_activate_license( true ); } if ( ! $this->has_free_plan() && ! $this->has_features_enabled_license() && ! $this->_has_premium_license() ) { // @todo Check if deactivate plugins also call the deactivation hook. $this->_parent->_admin_notices->add_sticky( sprintf( ( $is_after_trial_cancel ? $this->_parent->get_text_inline( '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.', 'addon-trial-cancelled-message' ) : $this->_parent->get_text_inline( '%s is a premium only add-on. You have to purchase a license first before activating the plugin.', 'addon-no-license-message' ) ), '<b>' . $this->_plugin->title . '</b>' ) . ' ' . sprintf( '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>', $this->_parent->addon_url( $this->_slug ), esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ), $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' ) ), 'no_addon_license_' . $this->_slug, ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ), ( $is_after_trial_cancel ? 'success' : 'error' ) ); deactivate_plugins( array( $this->_plugin_basename ), true ); return true; } } return false; }
php
private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) { if ( ! $this->has_free_plan() && ! $this->has_features_enabled_license() && ! $this->_has_premium_license() ) { if ( $this->is_registered() ) { // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons). // if (empty($this->_storage->activation_timestamp) || // (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30 // ) { /** * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation. * * Retry syncing the user add-on licenses. */ // Sync licenses. $this->_sync_licenses(); // } // Try to activate premium license. $this->_activate_license( true ); } if ( ! $this->has_free_plan() && ! $this->has_features_enabled_license() && ! $this->_has_premium_license() ) { // @todo Check if deactivate plugins also call the deactivation hook. $this->_parent->_admin_notices->add_sticky( sprintf( ( $is_after_trial_cancel ? $this->_parent->get_text_inline( '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.', 'addon-trial-cancelled-message' ) : $this->_parent->get_text_inline( '%s is a premium only add-on. You have to purchase a license first before activating the plugin.', 'addon-no-license-message' ) ), '<b>' . $this->_plugin->title . '</b>' ) . ' ' . sprintf( '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>', $this->_parent->addon_url( $this->_slug ), esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ), $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' ) ), 'no_addon_license_' . $this->_slug, ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ), ( $is_after_trial_cancel ? 'success' : 'error' ) ); deactivate_plugins( array( $this->_plugin_basename ), true ); return true; } } return false; }
[ "private", "function", "deactivate_premium_only_addon_without_license", "(", "$", "is_after_trial_cancel", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "has_free_plan", "(", ")", "&&", "!", "$", "this", "->", "has_features_enabled_license", "(", ")",...
Deactivate add-on if it's premium only and the user does't have a valid license. @param bool $is_after_trial_cancel @return bool If add-on was deactivated.
[ "Deactivate", "add", "-", "on", "if", "it", "s", "premium", "only", "and", "the", "user", "does", "t", "have", "a", "valid", "license", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5419-L5479
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.init_sandbox
function init_sandbox( $secret_key ) { $this->_plugin->secret_key = $secret_key; // Update plugin details. FS_Plugin_Manager::instance( $this->_module_id )->update( $this->_plugin, true ); }
php
function init_sandbox( $secret_key ) { $this->_plugin->secret_key = $secret_key; // Update plugin details. FS_Plugin_Manager::instance( $this->_module_id )->update( $this->_plugin, true ); }
[ "function", "init_sandbox", "(", "$", "secret_key", ")", "{", "$", "this", "->", "_plugin", "->", "secret_key", "=", "$", "secret_key", ";", "// Update plugin details.\r", "FS_Plugin_Manager", "::", "instance", "(", "$", "this", "->", "_module_id", ")", "->", ...
Set Freemius into sandbox mode for debugging. @author Vova Feldman (@svovaf) @since 1.0.4 @param string $secret_key
[ "Set", "Freemius", "into", "sandbox", "mode", "for", "debugging", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5495-L5500
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_network_anonymous
function is_network_anonymous() { if ( ! $this->_is_network_active ) { return false; } $is_anonymous_ms = $this->_storage->get( 'is_anonymous_ms' ); if ( empty( $is_anonymous_ms ) ) { return false; } return $is_anonymous_ms['is']; }
php
function is_network_anonymous() { if ( ! $this->_is_network_active ) { return false; } $is_anonymous_ms = $this->_storage->get( 'is_anonymous_ms' ); if ( empty( $is_anonymous_ms ) ) { return false; } return $is_anonymous_ms['is']; }
[ "function", "is_network_anonymous", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "return", "false", ";", "}", "$", "is_anonymous_ms", "=", "$", "this", "->", "_storage", "->", "get", "(", "'is_anonymous_ms'", ")", ";", ...
Check if super-admin skipped connection for all sites in the network. @author Vova Feldman (@svovaf) @since 2.0.0
[ "Check", "if", "super", "-", "admin", "skipped", "connection", "for", "all", "sites", "in", "the", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5534-L5546
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_anonymous
function is_anonymous() { if ( ! isset( $this->_is_anonymous ) ) { if ( $this->is_network_anonymous() ) { $this->_is_anonymous = true; } else if ( ! fs_is_network_admin() ) { if ( ! isset( $this->_storage->is_anonymous ) ) { // Not skipped. $this->_is_anonymous = false; } else if ( is_bool( $this->_storage->is_anonymous ) ) { // For back compatibility, since the variable was boolean before. $this->_is_anonymous = $this->_storage->is_anonymous; // Upgrade stored data format to 1.1.3 format. $this->set_anonymous_mode( $this->_storage->is_anonymous ); } else { // Version 1.1.3 and later. $this->_is_anonymous = $this->_storage->is_anonymous['is']; } } } return $this->_is_anonymous; }
php
function is_anonymous() { if ( ! isset( $this->_is_anonymous ) ) { if ( $this->is_network_anonymous() ) { $this->_is_anonymous = true; } else if ( ! fs_is_network_admin() ) { if ( ! isset( $this->_storage->is_anonymous ) ) { // Not skipped. $this->_is_anonymous = false; } else if ( is_bool( $this->_storage->is_anonymous ) ) { // For back compatibility, since the variable was boolean before. $this->_is_anonymous = $this->_storage->is_anonymous; // Upgrade stored data format to 1.1.3 format. $this->set_anonymous_mode( $this->_storage->is_anonymous ); } else { // Version 1.1.3 and later. $this->_is_anonymous = $this->_storage->is_anonymous['is']; } } } return $this->_is_anonymous; }
[ "function", "is_anonymous", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_is_anonymous", ")", ")", "{", "if", "(", "$", "this", "->", "is_network_anonymous", "(", ")", ")", "{", "$", "this", "->", "_is_anonymous", "=", "true", ";"...
Check if the user skipped connecting the account with Freemius. @author Vova Feldman (@svovaf) @since 1.0.7 @return bool
[ "Check", "if", "the", "user", "skipped", "connecting", "the", "account", "with", "Freemius", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5570-L5592
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_anonymous_site
function is_anonymous_site( $blog_id = 0 ) { if ( $this->is_network_anonymous() ) { return true; } $is_anonymous = $this->_storage->get( 'is_anonymous', false, $blog_id ); if ( empty( $is_anonymous ) ) { return false; } return $is_anonymous['is']; }
php
function is_anonymous_site( $blog_id = 0 ) { if ( $this->is_network_anonymous() ) { return true; } $is_anonymous = $this->_storage->get( 'is_anonymous', false, $blog_id ); if ( empty( $is_anonymous ) ) { return false; } return $is_anonymous['is']; }
[ "function", "is_anonymous_site", "(", "$", "blog_id", "=", "0", ")", "{", "if", "(", "$", "this", "->", "is_network_anonymous", "(", ")", ")", "{", "return", "true", ";", "}", "$", "is_anonymous", "=", "$", "this", "->", "_storage", "->", "get", "(", ...
Check if the user skipped the connection of a specified site. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id @return bool
[ "Check", "if", "the", "user", "skipped", "the", "connection", "of", "a", "specified", "site", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5604-L5616
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_cron_blog_id
private function get_cron_blog_id( $name ) { $this->_logger->entrance( $name ); /** * @var object $cron_data */ $cron_data = $this->get_cron_data( $name ); return ( is_object( $cron_data ) && is_numeric( $cron_data->blog_id ) ) ? $cron_data->blog_id : 0; }
php
private function get_cron_blog_id( $name ) { $this->_logger->entrance( $name ); /** * @var object $cron_data */ $cron_data = $this->get_cron_data( $name ); return ( is_object( $cron_data ) && is_numeric( $cron_data->blog_id ) ) ? $cron_data->blog_id : 0; }
[ "private", "function", "get_cron_blog_id", "(", "$", "name", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "name", ")", ";", "/**\r\n * @var object $cron_data\r\n */", "$", "cron_data", "=", "$", "this", "->", "get_cro...
Get the cron's executing blog ID. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $name Cron name. @return int
[ "Get", "the", "cron", "s", "executing", "blog", "ID", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5703-L5714
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.set_cron_execution_timestamp
private function set_cron_execution_timestamp( $name ) { $this->_logger->entrance( $name ); $this->_storage->store( "{$name}_timestamp", time() ); }
php
private function set_cron_execution_timestamp( $name ) { $this->_logger->entrance( $name ); $this->_storage->store( "{$name}_timestamp", time() ); }
[ "private", "function", "set_cron_execution_timestamp", "(", "$", "name", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "name", ")", ";", "$", "this", "->", "_storage", "->", "store", "(", "\"{$name}_timestamp\"", ",", "time", "(", ")"...
Set cron execution time to now. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $name Cron name.
[ "Set", "cron", "execution", "time", "to", "now", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5759-L5763
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.set_keepalive_timestamp
private function set_keepalive_timestamp( $use_network_level_storage = null ) { $this->_logger->entrance(); $this->_storage->store( 'keepalive_timestamp', time(), $use_network_level_storage ); }
php
private function set_keepalive_timestamp( $use_network_level_storage = null ) { $this->_logger->entrance(); $this->_storage->store( 'keepalive_timestamp', time(), $use_network_level_storage ); }
[ "private", "function", "set_keepalive_timestamp", "(", "$", "use_network_level_storage", "=", "null", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "_storage", "->", "store", "(", "'keepalive_timestamp'", ",", "tim...
Sets the keepalive time to now. @author Leo Fajardo (@leorw) @since 2.2.3 @param bool|null $use_network_level_storage
[ "Sets", "the", "keepalive", "time", "to", "now", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5773-L5777
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_cron_target_blog_id
private function get_cron_target_blog_id( $except_blog_id = 0 ) { if ( ! is_multisite() ) { return 0; } if ( $this->_is_network_active && is_numeric( $this->_storage->network_install_blog_id ) && $except_blog_id != $this->_storage->network_install_blog_id && self::is_site_active( $this->_storage->network_install_blog_id ) ) { // Try to run cron from the main network blog. $install = $this->get_install_by_blog_id( $this->_storage->network_install_blog_id ); if ( is_object( $install ) && ( $this->is_premium() || $install->is_tracking_allowed() ) ) { return $this->_storage->network_install_blog_id; } } // Get first opted-in blog ID with active tracking. $installs = $this->get_blog_install_map(); foreach ( $installs as $blog_id => $install ) { if ( $except_blog_id != $blog_id && self::is_site_active( $blog_id ) && ( $this->is_premium() || $install->is_tracking_allowed() ) ) { return $blog_id; } } return 0; }
php
private function get_cron_target_blog_id( $except_blog_id = 0 ) { if ( ! is_multisite() ) { return 0; } if ( $this->_is_network_active && is_numeric( $this->_storage->network_install_blog_id ) && $except_blog_id != $this->_storage->network_install_blog_id && self::is_site_active( $this->_storage->network_install_blog_id ) ) { // Try to run cron from the main network blog. $install = $this->get_install_by_blog_id( $this->_storage->network_install_blog_id ); if ( is_object( $install ) && ( $this->is_premium() || $install->is_tracking_allowed() ) ) { return $this->_storage->network_install_blog_id; } } // Get first opted-in blog ID with active tracking. $installs = $this->get_blog_install_map(); foreach ( $installs as $blog_id => $install ) { if ( $except_blog_id != $blog_id && self::is_site_active( $blog_id ) && ( $this->is_premium() || $install->is_tracking_allowed() ) ) { return $blog_id; } } return 0; }
[ "private", "function", "get_cron_target_blog_id", "(", "$", "except_blog_id", "=", "0", ")", "{", "if", "(", "!", "is_multisite", "(", ")", ")", "{", "return", "0", ";", "}", "if", "(", "$", "this", "->", "_is_network_active", "&&", "is_numeric", "(", "$...
WP Cron is executed on a site level. When running in a multisite network environment with the network integration activated, for optimization reasons, we are consolidating the installs data sync cron to be executed only from a single site. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $except_blog_id Target any except the excluded blog ID. @return int
[ "WP", "Cron", "is", "executed", "on", "a", "site", "level", ".", "When", "running", "in", "a", "multisite", "network", "environment", "with", "the", "network", "integration", "activated", "for", "optimization", "reasons", "we", "are", "consolidating", "the", "...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5814-L5846
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_next_scheduled_cron
private function get_next_scheduled_cron( $name, $action_tag = '' ) { $this->_logger->entrance( $name ); if ( ! $this->is_cron_on( $name ) ) { return false; } /** * @var object $cron_data */ $cron_data = $this->get_cron_data( $name ); $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ? $cron_data->blog_id : 0; if ( 0 < $cron_blog_id ) { switch_to_blog( $cron_blog_id ); } if ( empty( $action_tag ) ) { $action_tag = $name; } $next_scheduled = wp_next_scheduled( $this->get_action_tag( $action_tag ) ); if ( 0 < $cron_blog_id ) { restore_current_blog(); } return $next_scheduled; }
php
private function get_next_scheduled_cron( $name, $action_tag = '' ) { $this->_logger->entrance( $name ); if ( ! $this->is_cron_on( $name ) ) { return false; } /** * @var object $cron_data */ $cron_data = $this->get_cron_data( $name ); $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ? $cron_data->blog_id : 0; if ( 0 < $cron_blog_id ) { switch_to_blog( $cron_blog_id ); } if ( empty( $action_tag ) ) { $action_tag = $name; } $next_scheduled = wp_next_scheduled( $this->get_action_tag( $action_tag ) ); if ( 0 < $cron_blog_id ) { restore_current_blog(); } return $next_scheduled; }
[ "private", "function", "get_next_scheduled_cron", "(", "$", "name", ",", "$", "action_tag", "=", "''", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "name", ")", ";", "if", "(", "!", "$", "this", "->", "is_cron_on", "(", "$", "n...
Unix timestamp for next cron execution or false if not scheduled. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $name Cron name. @param string $action_tag Callback action tag. @return int|false
[ "Unix", "timestamp", "for", "next", "cron", "execution", "or", "false", "if", "not", "scheduled", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L5919-L5950
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.execute_cron
private function execute_cron( $name, $callable ) { $this->_logger->entrance( $name ); // Store the last time data sync was executed. $this->set_cron_execution_timestamp( $name ); // Check if API is temporary down. if ( FS_Api::is_temporary_down() ) { return; } // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours. $users_2_blog_ids = array(); if ( ! is_multisite() ) { // Add dummy blog. $users_2_blog_ids[0] = array( 0 ); } else { $installs = $this->get_blog_install_map(); foreach ( $installs as $blog_id => $install ) { if ( $this->is_premium() || $install->is_tracking_allowed() ) { if ( ! isset( $users_2_blog_ids[ $install->user_id ] ) ) { $users_2_blog_ids[ $install->user_id ] = array(); } $users_2_blog_ids[ $install->user_id ][] = $blog_id; } } } $current_blog_id = get_current_blog_id(); foreach ( $users_2_blog_ids as $user_id => $blog_ids ) { if ( 0 < $blog_ids[0] ) { $this->switch_to_blog( $blog_ids[0] ); } call_user_func_array( $callable, array( $blog_ids, ( is_multisite() ? $current_blog_id : null ) ) ); foreach ( $blog_ids as $blog_id ) { $this->do_action( "after_{$name}_cron", $blog_id ); } } if ( is_multisite() ) { $this->switch_to_blog( $current_blog_id ); $this->do_action( "after_{$name}_cron_multisite" ); } }
php
private function execute_cron( $name, $callable ) { $this->_logger->entrance( $name ); // Store the last time data sync was executed. $this->set_cron_execution_timestamp( $name ); // Check if API is temporary down. if ( FS_Api::is_temporary_down() ) { return; } // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours. $users_2_blog_ids = array(); if ( ! is_multisite() ) { // Add dummy blog. $users_2_blog_ids[0] = array( 0 ); } else { $installs = $this->get_blog_install_map(); foreach ( $installs as $blog_id => $install ) { if ( $this->is_premium() || $install->is_tracking_allowed() ) { if ( ! isset( $users_2_blog_ids[ $install->user_id ] ) ) { $users_2_blog_ids[ $install->user_id ] = array(); } $users_2_blog_ids[ $install->user_id ][] = $blog_id; } } } $current_blog_id = get_current_blog_id(); foreach ( $users_2_blog_ids as $user_id => $blog_ids ) { if ( 0 < $blog_ids[0] ) { $this->switch_to_blog( $blog_ids[0] ); } call_user_func_array( $callable, array( $blog_ids, ( is_multisite() ? $current_blog_id : null ) ) ); foreach ( $blog_ids as $blog_id ) { $this->do_action( "after_{$name}_cron", $blog_id ); } } if ( is_multisite() ) { $this->switch_to_blog( $current_blog_id ); $this->do_action( "after_{$name}_cron_multisite" ); } }
[ "private", "function", "execute_cron", "(", "$", "name", ",", "$", "callable", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "name", ")", ";", "// Store the last time data sync was executed.\r", "$", "this", "->", "set_cron_execution_timestam...
Consolidated cron execution for performance optimization. The max number of API requests is based on the number of unique opted-in users. that doesn't halt page loading. @author Vova Feldman (@svovaf) @since 2.0.0 @param string $name Cron name. @param callable $callable The function that should be executed.
[ "Consolidated", "cron", "execution", "for", "performance", "optimization", ".", "The", "max", "number", "of", "API", "requests", "is", "based", "on", "the", "number", "of", "unique", "opted", "-", "in", "users", ".", "that", "doesn", "t", "halt", "page", "...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6023-L6073
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._sync_cron_method
function _sync_cron_method( array $blog_ids, $current_blog_id = null ) { if ( $this->is_registered() ) { if ( $this->has_paid_plan() ) { // Initiate background plan sync. $this->_sync_license( true, false, $current_blog_id ); if ( $this->is_paying() ) { // Check for premium plugin updates. $this->check_updates( true ); } } else { // Sync install(s) (only if something changed locally). if ( 1 < count( $blog_ids ) ) { $this->sync_installs(); } else { $this->sync_install(); } } } }
php
function _sync_cron_method( array $blog_ids, $current_blog_id = null ) { if ( $this->is_registered() ) { if ( $this->has_paid_plan() ) { // Initiate background plan sync. $this->_sync_license( true, false, $current_blog_id ); if ( $this->is_paying() ) { // Check for premium plugin updates. $this->check_updates( true ); } } else { // Sync install(s) (only if something changed locally). if ( 1 < count( $blog_ids ) ) { $this->sync_installs(); } else { $this->sync_install(); } } } }
[ "function", "_sync_cron_method", "(", "array", "$", "blog_ids", ",", "$", "current_blog_id", "=", "null", ")", "{", "if", "(", "$", "this", "->", "is_registered", "(", ")", ")", "{", "if", "(", "$", "this", "->", "has_paid_plan", "(", ")", ")", "{", ...
The actual data sync cron logic. @author Vova Feldman (@svovaf) @since 2.0.0 @param int[] $blog_ids @param int|null $current_blog_id @since 2.2.3. This is passed from the `execute_cron` method and used by the `_sync_plugin_license` method in order to switch to the previous blog when sending updates for a single site in case `execute_cron` has switched to a different blog.
[ "The", "actual", "data", "sync", "cron", "logic", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6147-L6166
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._add_pending_activation_notice
function _add_pending_activation_notice( $email = false, $is_pending_trial = false ) { if ( ! is_string( $email ) ) { $current_user = self::_get_current_wp_user(); $email = $current_user->user_email; } $this->_admin_notices->add_sticky( sprintf( $this->get_text_inline( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.', 'pending-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>', '<b>' . $email . '</b>', ( $is_pending_trial ? $this->get_text_inline( 'start the trial', 'start-the-trial' ) : $this->get_text_inline( 'complete the install', 'complete-the-install' ) ) ), 'activation_pending', 'Thanks!' ); }
php
function _add_pending_activation_notice( $email = false, $is_pending_trial = false ) { if ( ! is_string( $email ) ) { $current_user = self::_get_current_wp_user(); $email = $current_user->user_email; } $this->_admin_notices->add_sticky( sprintf( $this->get_text_inline( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.', 'pending-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>', '<b>' . $email . '</b>', ( $is_pending_trial ? $this->get_text_inline( 'start the trial', 'start-the-trial' ) : $this->get_text_inline( 'complete the install', 'complete-the-install' ) ) ), 'activation_pending', 'Thanks!' ); }
[ "function", "_add_pending_activation_notice", "(", "$", "email", "=", "false", ",", "$", "is_pending_trial", "=", "false", ")", "{", "if", "(", "!", "is_string", "(", "$", "email", ")", ")", "{", "$", "current_user", "=", "self", "::", "_get_current_wp_user"...
Show a notice that activation is currently pending. @author Vova Feldman (@svovaf) @since 1.0.7 @param bool|string $email @param bool $is_pending_trial Since 1.2.1.5
[ "Show", "a", "notice", "that", "activation", "is", "currently", "pending", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6390-L6408
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.current_page_url
function current_page_url() { $url = 'http'; if ( isset( $_SERVER["HTTPS"] ) ) { if ( $_SERVER["HTTPS"] == "on" ) { $url .= "s"; } } $url .= "://"; if ( $_SERVER["SERVER_PORT"] != "80" ) { $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return esc_url( $url ); }
php
function current_page_url() { $url = 'http'; if ( isset( $_SERVER["HTTPS"] ) ) { if ( $_SERVER["HTTPS"] == "on" ) { $url .= "s"; } } $url .= "://"; if ( $_SERVER["SERVER_PORT"] != "80" ) { $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return esc_url( $url ); }
[ "function", "current_page_url", "(", ")", "{", "$", "url", "=", "'http'", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "\"HTTPS\"", "]", ")", ")", "{", "if", "(", "$", "_SERVER", "[", "\"HTTPS\"", "]", "==", "\"on\"", ")", "{", "$", "url", ...
Return current page's URL. @author Vova Feldman (@svovaf) @since 1.0.7 @return string
[ "Return", "current", "page", "s", "URL", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6682-L6698
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._delete_plans
private function _delete_plans( $store = true, $keep_associated_plans = true ) { $this->_logger->entrance(); $plans = self::get_all_plans( $this->_module_type ); $plans_to_keep = array(); if ( $keep_associated_plans ) { $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs(); foreach ( $plans_ids_to_keep as $plan_id ) { $plan = self::_get_plan_by_id( $plan_id ); if ( is_object( $plan ) ) { $plans_to_keep[] = $plan; } } } if ( ! empty( $plans_to_keep ) ) { $plans[ $this->_slug ] = $plans_to_keep; } else { unset( $plans[ $this->_slug ] ); } $this->set_account_option( 'plans', $plans, $store ); }
php
private function _delete_plans( $store = true, $keep_associated_plans = true ) { $this->_logger->entrance(); $plans = self::get_all_plans( $this->_module_type ); $plans_to_keep = array(); if ( $keep_associated_plans ) { $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs(); foreach ( $plans_ids_to_keep as $plan_id ) { $plan = self::_get_plan_by_id( $plan_id ); if ( is_object( $plan ) ) { $plans_to_keep[] = $plan; } } } if ( ! empty( $plans_to_keep ) ) { $plans[ $this->_slug ] = $plans_to_keep; } else { unset( $plans[ $this->_slug ] ); } $this->set_account_option( 'plans', $plans, $store ); }
[ "private", "function", "_delete_plans", "(", "$", "store", "=", "true", ",", "$", "keep_associated_plans", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "plans", "=", "self", "::", "get_all_plans", "(", "$", ...
Delete plugin's plans information. @param bool $store Flush to Database if true. @param bool $keep_associated_plans If set to false, delete all plans, even if a plan is associated with an install. @author Vova Feldman (@svovaf) @since 1.0.9
[ "Delete", "plugin", "s", "plans", "information", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6795-L6819
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._delete_licenses
private function _delete_licenses( $store = true ) { $this->_logger->entrance(); $all_licenses = self::get_all_licenses(); unset( $all_licenses[ $this->_module_id ] ); self::$_accounts->set_option( 'all_licenses', $all_licenses, $store ); }
php
private function _delete_licenses( $store = true ) { $this->_logger->entrance(); $all_licenses = self::get_all_licenses(); unset( $all_licenses[ $this->_module_id ] ); self::$_accounts->set_option( 'all_licenses', $all_licenses, $store ); }
[ "private", "function", "_delete_licenses", "(", "$", "store", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "all_licenses", "=", "self", "::", "get_all_licenses", "(", ")", ";", "unset", "(", "$", "all_license...
Delete all plugin licenses. @author Vova Feldman (@svovaf) @since 1.0.9 @param bool $store
[ "Delete", "all", "plugin", "licenses", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6829-L6837
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._activate_theme_event_hook
function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) { $this->_storage->previous_theme = ( false !== $old_theme ) ? $old_theme->get_stylesheet() : $slug_or_name; $this->_activate_plugin_event_hook(); }
php
function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) { $this->_storage->previous_theme = ( false !== $old_theme ) ? $old_theme->get_stylesheet() : $slug_or_name; $this->_activate_plugin_event_hook(); }
[ "function", "_activate_theme_event_hook", "(", "$", "slug_or_name", ",", "$", "old_theme", "=", "false", ")", "{", "$", "this", "->", "_storage", "->", "previous_theme", "=", "(", "false", "!==", "$", "old_theme", ")", "?", "$", "old_theme", "->", "get_style...
Saves the slug of the previous theme if it still exists so that it can be used by the logic in the opt-in form that decides whether to add a close button to the opt-in dialog or not. So after a premium-only theme is activated, the close button will appear and will reactivate the previous theme if clicked. If the previous theme doesn't exist, then there will be no close button. @author Leo Fajardo (@leorw) @since 1.2.2 @param string $slug_or_name Old theme's slug or name. @param bool|WP_Theme $old_theme WP_Theme instance of the old theme if it still exists.
[ "Saves", "the", "slug", "of", "the", "previous", "theme", "if", "it", "still", "exists", "so", "that", "it", "can", "be", "used", "by", "the", "logic", "in", "the", "opt", "-", "in", "form", "that", "decides", "whether", "to", "add", "a", "close", "b...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L6948-L6954
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.delete_account_event
function delete_account_event( $check_user = true ) { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( $check_user && ! $this->is_user_admin() ) { return; } $this->do_action( 'before_account_delete' ); // Clear all admin notices. $this->_admin_notices->clear_all_sticky( false ); $this->_delete_site( false ); $delete_network_common_data = true; if ( $this->_is_network_active ) { $installs = $this->get_blog_install_map(); // Don't delete common network data unless no other installs left. $delete_network_common_data = empty( $installs ); } if ( $delete_network_common_data ) { $this->_delete_plans( false ); $this->_delete_licenses( false ); // Delete add-ons related to plugin's account. $this->_delete_account_addons( false ); } // @todo Delete plans and licenses of add-ons. self::$_accounts->store(); /** * IMPORTANT: * Clear crons must be executed before clearing all storage. * Otherwise, the cron will not be cleared. */ if ( $delete_network_common_data ) { $this->clear_sync_cron(); } $this->clear_install_sync_cron(); // Clear all storage data. $this->_storage->clear_all( true, array( 'connectivity_test', 'is_on', ), false ); // Send delete event. $this->get_api_site_scope()->call( '/', 'delete' ); $this->do_action( 'after_account_delete' ); }
php
function delete_account_event( $check_user = true ) { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( $check_user && ! $this->is_user_admin() ) { return; } $this->do_action( 'before_account_delete' ); // Clear all admin notices. $this->_admin_notices->clear_all_sticky( false ); $this->_delete_site( false ); $delete_network_common_data = true; if ( $this->_is_network_active ) { $installs = $this->get_blog_install_map(); // Don't delete common network data unless no other installs left. $delete_network_common_data = empty( $installs ); } if ( $delete_network_common_data ) { $this->_delete_plans( false ); $this->_delete_licenses( false ); // Delete add-ons related to plugin's account. $this->_delete_account_addons( false ); } // @todo Delete plans and licenses of add-ons. self::$_accounts->store(); /** * IMPORTANT: * Clear crons must be executed before clearing all storage. * Otherwise, the cron will not be cleared. */ if ( $delete_network_common_data ) { $this->clear_sync_cron(); } $this->clear_install_sync_cron(); // Clear all storage data. $this->_storage->clear_all( true, array( 'connectivity_test', 'is_on', ), false ); // Send delete event. $this->get_api_site_scope()->call( '/', 'delete' ); $this->do_action( 'after_account_delete' ); }
[ "function", "delete_account_event", "(", "$", "check_user", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "'slug = '", ".", "$", "this", "->", "_slug", ")", ";", "if", "(", "$", "check_user", "&&", "!", "$", "this", "->", ...
Delete account. @author Vova Feldman (@svovaf) @since 1.0.3 @param bool $check_user Enforce checking if user have plugins activation privileges.
[ "Delete", "account", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7120-L7177
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.delete_network_account_event
function delete_network_account_event( $check_user = true ) { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( $check_user && ! $this->is_user_admin() ) { return; } $this->do_action( 'before_network_account_delete' ); // Clear all admin notices. $this->_admin_notices->clear_all_sticky(); $this->_delete_plans( false, false ); $this->_delete_licenses( false ); // Delete add-ons related to plugin's account. $this->_delete_account_addons( false ); // @todo Delete plans and licenses of add-ons. self::$_accounts->store( true ); /** * IMPORTANT: * Clear crons must be executed before clearing all storage. * Otherwise, the cron will not be cleared. */ $this->clear_sync_cron( true ); $this->clear_install_sync_cron( true ); $sites = self::get_sites(); $install_ids = array(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install_id = $this->_delete_site( true, $blog_id ); // Clear all storage data. $this->_storage->clear_all( true, array( 'connectivity_test' ), $blog_id ); if ( FS_Site::is_valid_id( $install_id ) ) { $install_ids[] = $install_id; } switch_to_blog( $blog_id ); $this->do_action( 'after_account_delete' ); restore_current_blog(); } $this->_storage->clear_all( true, array( 'connectivity_test', 'is_on', ), true ); // Send delete event. if ( ! empty( $install_ids ) ) { $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', $install_ids ), 'delete' ); } $this->do_action( 'after_network_account_delete' ); }
php
function delete_network_account_event( $check_user = true ) { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( $check_user && ! $this->is_user_admin() ) { return; } $this->do_action( 'before_network_account_delete' ); // Clear all admin notices. $this->_admin_notices->clear_all_sticky(); $this->_delete_plans( false, false ); $this->_delete_licenses( false ); // Delete add-ons related to plugin's account. $this->_delete_account_addons( false ); // @todo Delete plans and licenses of add-ons. self::$_accounts->store( true ); /** * IMPORTANT: * Clear crons must be executed before clearing all storage. * Otherwise, the cron will not be cleared. */ $this->clear_sync_cron( true ); $this->clear_install_sync_cron( true ); $sites = self::get_sites(); $install_ids = array(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install_id = $this->_delete_site( true, $blog_id ); // Clear all storage data. $this->_storage->clear_all( true, array( 'connectivity_test' ), $blog_id ); if ( FS_Site::is_valid_id( $install_id ) ) { $install_ids[] = $install_id; } switch_to_blog( $blog_id ); $this->do_action( 'after_account_delete' ); restore_current_blog(); } $this->_storage->clear_all( true, array( 'connectivity_test', 'is_on', ), true ); // Send delete event. if ( ! empty( $install_ids ) ) { $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', $install_ids ), 'delete' ); } $this->do_action( 'after_network_account_delete' ); }
[ "function", "delete_network_account_event", "(", "$", "check_user", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "'slug = '", ".", "$", "this", "->", "_slug", ")", ";", "if", "(", "$", "check_user", "&&", "!", "$", "this", ...
Delete network level account. @author Vova Feldman (@svovaf) @since 2.0.0 @param bool $check_user Enforce checking if user have plugins activation privileges.
[ "Delete", "network", "level", "account", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7187-L7251
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._deactivate_plugin_hook
function _deactivate_plugin_hook() { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( ! $this->is_user_admin() ) { return; } $is_network_deactivation = fs_is_network_admin(); $storage_keys_for_removal = array(); $this->_admin_notices->clear_all_sticky(); $storage_keys_for_removal[] = 'sticky_optin_added'; if ( isset( $this->_storage->sticky_optin_added ) ) { unset( $this->_storage->sticky_optin_added ); } if ( ! isset( $this->_storage->is_plugin_new_install ) ) { // Remember that plugin was already installed. $this->_storage->is_plugin_new_install = false; } // Hook to plugin uninstall. register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) ); $this->clear_module_main_file_cache(); $this->clear_sync_cron( $this->_is_network_active ); $this->clear_install_sync_cron(); if ( $this->is_registered() ) { if ( $this->is_premium() && ! $this->has_active_valid_license() ) { FS_Plugin_Updater::instance( $this )->delete_update_data(); } if ( $is_network_deactivation ) { // Send deactivation event. $this->sync_installs( array( 'is_active' => false, ) ); } else { // Send deactivation event. $this->sync_install( array( 'is_active' => false, ) ); } } else { if ( ! $this->has_api_connectivity() ) { // Reset connectivity test cache. unset( $this->_storage->connectivity_test ); $storage_keys_for_removal[] = 'connectivity_test'; } } if ( $is_network_deactivation ) { if ( isset( $this->_storage->sticky_optin_added_ms ) ) { unset( $this->_storage->sticky_optin_added_ms ); } if ( ! empty( $storage_keys_for_removal ) ) { $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); foreach ( $storage_keys_for_removal as $key ) { $this->_storage->remove( $key, false, $blog_id ); } $this->_storage->save( $blog_id ); } } } // Clear API cache on deactivation. FS_Api::clear_cache(); $this->remove_sdk_reference(); }
php
function _deactivate_plugin_hook() { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( ! $this->is_user_admin() ) { return; } $is_network_deactivation = fs_is_network_admin(); $storage_keys_for_removal = array(); $this->_admin_notices->clear_all_sticky(); $storage_keys_for_removal[] = 'sticky_optin_added'; if ( isset( $this->_storage->sticky_optin_added ) ) { unset( $this->_storage->sticky_optin_added ); } if ( ! isset( $this->_storage->is_plugin_new_install ) ) { // Remember that plugin was already installed. $this->_storage->is_plugin_new_install = false; } // Hook to plugin uninstall. register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) ); $this->clear_module_main_file_cache(); $this->clear_sync_cron( $this->_is_network_active ); $this->clear_install_sync_cron(); if ( $this->is_registered() ) { if ( $this->is_premium() && ! $this->has_active_valid_license() ) { FS_Plugin_Updater::instance( $this )->delete_update_data(); } if ( $is_network_deactivation ) { // Send deactivation event. $this->sync_installs( array( 'is_active' => false, ) ); } else { // Send deactivation event. $this->sync_install( array( 'is_active' => false, ) ); } } else { if ( ! $this->has_api_connectivity() ) { // Reset connectivity test cache. unset( $this->_storage->connectivity_test ); $storage_keys_for_removal[] = 'connectivity_test'; } } if ( $is_network_deactivation ) { if ( isset( $this->_storage->sticky_optin_added_ms ) ) { unset( $this->_storage->sticky_optin_added_ms ); } if ( ! empty( $storage_keys_for_removal ) ) { $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); foreach ( $storage_keys_for_removal as $key ) { $this->_storage->remove( $key, false, $blog_id ); } $this->_storage->save( $blog_id ); } } } // Clear API cache on deactivation. FS_Api::clear_cache(); $this->remove_sdk_reference(); }
[ "function", "_deactivate_plugin_hook", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "'slug = '", ".", "$", "this", "->", "_slug", ")", ";", "if", "(", "!", "$", "this", "->", "is_user_admin", "(", ")", ")", "{", "return", ";", ...
Plugin deactivation hook. @author Vova Feldman (@svovaf) @since 1.0.1
[ "Plugin", "deactivation", "hook", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7259-L7337
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.maybe_set_slug_and_network_menu_exists_flag
private function maybe_set_slug_and_network_menu_exists_flag() { if ( ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) { $this->_menu->set_slug_and_network_menu_exists_flag( $this->_menu->has_menu() ? $this->_menu->get_slug() : $this->_slug ); } }
php
private function maybe_set_slug_and_network_menu_exists_flag() { if ( ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) { $this->_menu->set_slug_and_network_menu_exists_flag( $this->_menu->has_menu() ? $this->_menu->get_slug() : $this->_slug ); } }
[ "private", "function", "maybe_set_slug_and_network_menu_exists_flag", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_dynamically_added_top_level_page_hook_name", ")", ")", "{", "$", "this", "->", "_menu", "->", "set_slug_and_network_menu_exists_flag",...
This is used to ensure that before redirecting to the opt-in page after resetting the anonymous mode or deleting the account in the network level, the URL of the page to redirect to is correct. @author Leo Fajardo (@leorw) @since 2.1.3
[ "This", "is", "used", "to", "ensure", "that", "before", "redirecting", "to", "the", "opt", "-", "in", "page", "after", "resetting", "the", "anonymous", "mode", "or", "deleting", "the", "account", "in", "the", "network", "level", "the", "URL", "of", "the", ...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7536-L7543
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.connect_again
function connect_again() { if ( ! $this->is_anonymous() ) { return; } $this->reset_anonymous_mode( fs_is_network_admin() ); $this->maybe_set_slug_and_network_menu_exists_flag(); fs_redirect( $this->get_activation_url() ); }
php
function connect_again() { if ( ! $this->is_anonymous() ) { return; } $this->reset_anonymous_mode( fs_is_network_admin() ); $this->maybe_set_slug_and_network_menu_exists_flag(); fs_redirect( $this->get_activation_url() ); }
[ "function", "connect_again", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_anonymous", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "reset_anonymous_mode", "(", "fs_is_network_admin", "(", ")", ")", ";", "$", "this", "->", "maybe_...
Clears the anonymous mode and redirects to the opt-in screen. @author Vova Feldman (@svovaf) @since 1.1.7
[ "Clears", "the", "anonymous", "mode", "and", "redirects", "to", "the", "opt", "-", "in", "screen", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7551-L7561
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.skip_connection
function skip_connection( $sites = null, $skip_all_network = false ) { $this->_logger->entrance(); $this->_admin_notices->remove_sticky( 'connect_account' ); if ( $skip_all_network ) { $this->set_anonymous_mode( true, true ); } if ( ! $skip_all_network && empty( $sites ) ) { $this->skip_site_connection(); } else { $uids = array(); if ( $skip_all_network ) { $this->set_anonymous_mode( true, true ); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $this->skip_site_connection( $blog_id, false ); $uids[] = $this->get_anonymous_id( $blog_id ); } } else if ( ! empty( $sites ) ) { foreach ( $sites as $site ) { $uids[] = $site['uid']; $this->skip_site_connection( $site['blog_id'], false ); } } // Send anonymous skip event. // No user identified info nor any tracking will be sent after the user skips the opt-in. $this->get_api_plugin_scope()->call( 'skip.json', 'put', array( 'uids' => $uids, ) ); } $this->network_upgrade_mode_completed(); }
php
function skip_connection( $sites = null, $skip_all_network = false ) { $this->_logger->entrance(); $this->_admin_notices->remove_sticky( 'connect_account' ); if ( $skip_all_network ) { $this->set_anonymous_mode( true, true ); } if ( ! $skip_all_network && empty( $sites ) ) { $this->skip_site_connection(); } else { $uids = array(); if ( $skip_all_network ) { $this->set_anonymous_mode( true, true ); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $this->skip_site_connection( $blog_id, false ); $uids[] = $this->get_anonymous_id( $blog_id ); } } else if ( ! empty( $sites ) ) { foreach ( $sites as $site ) { $uids[] = $site['uid']; $this->skip_site_connection( $site['blog_id'], false ); } } // Send anonymous skip event. // No user identified info nor any tracking will be sent after the user skips the opt-in. $this->get_api_plugin_scope()->call( 'skip.json', 'put', array( 'uids' => $uids, ) ); } $this->network_upgrade_mode_completed(); }
[ "function", "skip_connection", "(", "$", "sites", "=", "null", ",", "$", "skip_all_network", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "_admin_notices", "->", "remove_sticky", "(", "'connect_a...
Skip account connect, and set anonymous mode. @author Vova Feldman (@svovaf) @since 1.1.1 @param array|null $sites Since 2.0.0. Specific sites. @param bool $skip_all_network Since 2.0.0. If true, skip connection for all sites.
[ "Skip", "account", "connect", "and", "set", "anonymous", "mode", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7572-L7610
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.skip_site_connection
private function skip_site_connection( $blog_id = null, $send_skip = true ) { $this->_logger->entrance(); $this->_admin_notices->remove_sticky( 'connect_account', $blog_id ); $this->set_anonymous_mode( true, $blog_id ); if ( $send_skip ) { $this->get_api_plugin_scope()->call( 'skip.json', 'put', array( 'uids' => array( $this->get_anonymous_id( $blog_id ) ), ) ); } }
php
private function skip_site_connection( $blog_id = null, $send_skip = true ) { $this->_logger->entrance(); $this->_admin_notices->remove_sticky( 'connect_account', $blog_id ); $this->set_anonymous_mode( true, $blog_id ); if ( $send_skip ) { $this->get_api_plugin_scope()->call( 'skip.json', 'put', array( 'uids' => array( $this->get_anonymous_id( $blog_id ) ), ) ); } }
[ "private", "function", "skip_site_connection", "(", "$", "blog_id", "=", "null", ",", "$", "send_skip", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "_admin_notices", "->", "remove_sticky", "(", ...
Skip connection for specific site in the network. @author Vova Feldman (@svovaf) @since 2.0.0 @param int|null $blog_id @param bool $send_skip
[ "Skip", "connection", "for", "specific", "site", "in", "the", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7621-L7633
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_plugins_thumbprint
private function get_plugins_thumbprint( $plugins ) { ksort( $plugins ); $thumbprint = ''; foreach ( $plugins as $basename => $data ) { $thumbprint .= $data['slug'] . ',' . $data['Version'] . ',' . ( $data['is_active'] ? '1' : '0' ) . ';'; } return md5( $thumbprint ); }
php
private function get_plugins_thumbprint( $plugins ) { ksort( $plugins ); $thumbprint = ''; foreach ( $plugins as $basename => $data ) { $thumbprint .= $data['slug'] . ',' . $data['Version'] . ',' . ( $data['is_active'] ? '1' : '0' ) . ';'; } return md5( $thumbprint ); }
[ "private", "function", "get_plugins_thumbprint", "(", "$", "plugins", ")", "{", "ksort", "(", "$", "plugins", ")", ";", "$", "thumbprint", "=", "''", ";", "foreach", "(", "$", "plugins", "as", "$", "basename", "=>", "$", "data", ")", "{", "$", "thumbpr...
Generate an MD5 signature of a plugins collection. This helper methods used to identify changes in a plugins collection. @author Vova Feldman (@svovaf) @since 2.0.0 @param array [string]array $plugins @return string
[ "Generate", "an", "MD5", "signature", "of", "a", "plugins", "collection", ".", "This", "helper", "methods", "used", "to", "identify", "changes", "in", "a", "plugins", "collection", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7663-L7674
train