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/class-freemius.php
Freemius.get_install_data_for_api
private function get_install_data_for_api( array $override, $include_plugins = true, $include_themes = true ) { if ( ! defined( 'WP_FS__TRACK_PLUGINS' ) || false !== WP_FS__TRACK_PLUGINS ) { /** * @since 1.1.8 Also send plugin updates. */ if ( $include_plugins && ! isset( $override['plugins'] ) ) { $plugins = $this->get_plugins_data_for_api(); if ( ! empty( $plugins ) ) { $override['plugins'] = $plugins; } } } if ( ! defined( 'WP_FS__TRACK_THEMES' ) || false !== WP_FS__TRACK_THEMES ) { /** * @since 1.1.8 Also send themes updates. */ if ( $include_themes && ! isset( $override['themes'] ) ) { $themes = $this->get_themes_data_for_api(); if ( ! empty( $themes ) ) { $override['themes'] = $themes; } } } $versions = $this->get_versions(); return array_merge( $versions, array( 'version' => $this->get_plugin_version(), 'is_premium' => $this->is_premium(), 'language' => get_bloginfo( 'language' ), 'charset' => get_bloginfo( 'charset' ), 'title' => get_bloginfo( 'name' ), 'url' => get_site_url(), // Special params. 'is_active' => true, 'is_disconnected' => $this->is_tracking_prohibited(), 'is_uninstalled' => false, ), $override ); }
php
private function get_install_data_for_api( array $override, $include_plugins = true, $include_themes = true ) { if ( ! defined( 'WP_FS__TRACK_PLUGINS' ) || false !== WP_FS__TRACK_PLUGINS ) { /** * @since 1.1.8 Also send plugin updates. */ if ( $include_plugins && ! isset( $override['plugins'] ) ) { $plugins = $this->get_plugins_data_for_api(); if ( ! empty( $plugins ) ) { $override['plugins'] = $plugins; } } } if ( ! defined( 'WP_FS__TRACK_THEMES' ) || false !== WP_FS__TRACK_THEMES ) { /** * @since 1.1.8 Also send themes updates. */ if ( $include_themes && ! isset( $override['themes'] ) ) { $themes = $this->get_themes_data_for_api(); if ( ! empty( $themes ) ) { $override['themes'] = $themes; } } } $versions = $this->get_versions(); return array_merge( $versions, array( 'version' => $this->get_plugin_version(), 'is_premium' => $this->is_premium(), 'language' => get_bloginfo( 'language' ), 'charset' => get_bloginfo( 'charset' ), 'title' => get_bloginfo( 'name' ), 'url' => get_site_url(), // Special params. 'is_active' => true, 'is_disconnected' => $this->is_tracking_prohibited(), 'is_uninstalled' => false, ), $override ); }
[ "private", "function", "get_install_data_for_api", "(", "array", "$", "override", ",", "$", "include_plugins", "=", "true", ",", "$", "include_themes", "=", "true", ")", "{", "if", "(", "!", "defined", "(", "'WP_FS__TRACK_PLUGINS'", ")", "||", "false", "!==", ...
Get site data for API install request. @author Vova Feldman (@svovaf) @since 1.1.2 @param string[] string $override @param bool $include_plugins Since 1.1.8 by default include plugin changes. @param bool $include_themes Since 1.1.8 by default include plugin changes. @return array
[ "Get", "site", "data", "for", "API", "install", "request", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L7994-L8037
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_installs_data_for_api
private function get_installs_data_for_api( array $override, $only_diff = false, $include_plugins = true, $include_themes = true ) { /** * @since 1.1.8 Also send plugin updates. */ // if ( $include_plugins && ! isset( $override['plugins'] ) ) { // $plugins = $this->get_plugins_data_for_api(); // if ( ! empty( $plugins ) ) { // $override['plugins'] = $plugins; // } // } /** * @since 1.1.8 Also send themes updates. */ // if ( $include_themes && ! isset( $override['themes'] ) ) { // $themes = $this->get_themes_data_for_api(); // if ( ! empty( $themes ) ) { // $override['themes'] = $themes; // } // } // Common properties. $versions = $this->get_versions(); $common = array_merge( $versions, array( 'version' => $this->get_plugin_version(), 'is_premium' => $this->is_premium(), ), $override ); $is_common_diff_for_any_site = false; $common_diff_union = array(); $installs_data = array(); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( is_object( $install ) ) { if ( $install->user_id != $this->_user->id ) { // Install belongs to a different owner. continue; } if ( ! $this->is_premium() && $install->is_tracking_prohibited() ) { // Don't send updates regarding opted-out installs. continue; } $install_data = $this->get_site_info( $site ); $uid = $install_data['uid']; unset( $install_data['blog_id'] ); unset( $install_data['uid'] ); $install_data['is_disconnected'] = $install->is_disconnected; $install_data['is_active'] = $this->is_active_for_site( $blog_id ); $install_data['is_uninstalled'] = $install->is_uninstalled; $common_diff = null; $is_common_diff = false; if ( $only_diff ) { $install_data = $this->get_install_diff_for_api( $install_data, $install, $override ); $common_diff = $this->get_install_diff_for_api( $common, $install, $override ); $is_common_diff = ! empty( $common_diff ); if ( $is_common_diff ) { foreach ( $common_diff as $k => $v ) { if ( ! isset( $common_diff_union[ $k ] ) ) { $common_diff_union[ $k ] = $v; } } } $is_common_diff_for_any_site = $is_common_diff_for_any_site || $is_common_diff; } if ( ! empty( $install_data ) || $is_common_diff ) { // Add install ID and site unique ID. $install_data['id'] = $install->id; $install_data['uid'] = $uid; $installs_data[] = $install_data; } } } restore_current_blog(); if ( 0 < count( $installs_data ) && ( $is_common_diff_for_any_site || ! $only_diff ) ) { if ( ! $only_diff ) { $installs_data[] = $common; } else if ( ! empty( $common_diff_union ) ) { $installs_data[] = $common_diff_union; } } foreach ( $installs_data as &$data ) { $data = (object) $data; } return $installs_data; }
php
private function get_installs_data_for_api( array $override, $only_diff = false, $include_plugins = true, $include_themes = true ) { /** * @since 1.1.8 Also send plugin updates. */ // if ( $include_plugins && ! isset( $override['plugins'] ) ) { // $plugins = $this->get_plugins_data_for_api(); // if ( ! empty( $plugins ) ) { // $override['plugins'] = $plugins; // } // } /** * @since 1.1.8 Also send themes updates. */ // if ( $include_themes && ! isset( $override['themes'] ) ) { // $themes = $this->get_themes_data_for_api(); // if ( ! empty( $themes ) ) { // $override['themes'] = $themes; // } // } // Common properties. $versions = $this->get_versions(); $common = array_merge( $versions, array( 'version' => $this->get_plugin_version(), 'is_premium' => $this->is_premium(), ), $override ); $is_common_diff_for_any_site = false; $common_diff_union = array(); $installs_data = array(); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( is_object( $install ) ) { if ( $install->user_id != $this->_user->id ) { // Install belongs to a different owner. continue; } if ( ! $this->is_premium() && $install->is_tracking_prohibited() ) { // Don't send updates regarding opted-out installs. continue; } $install_data = $this->get_site_info( $site ); $uid = $install_data['uid']; unset( $install_data['blog_id'] ); unset( $install_data['uid'] ); $install_data['is_disconnected'] = $install->is_disconnected; $install_data['is_active'] = $this->is_active_for_site( $blog_id ); $install_data['is_uninstalled'] = $install->is_uninstalled; $common_diff = null; $is_common_diff = false; if ( $only_diff ) { $install_data = $this->get_install_diff_for_api( $install_data, $install, $override ); $common_diff = $this->get_install_diff_for_api( $common, $install, $override ); $is_common_diff = ! empty( $common_diff ); if ( $is_common_diff ) { foreach ( $common_diff as $k => $v ) { if ( ! isset( $common_diff_union[ $k ] ) ) { $common_diff_union[ $k ] = $v; } } } $is_common_diff_for_any_site = $is_common_diff_for_any_site || $is_common_diff; } if ( ! empty( $install_data ) || $is_common_diff ) { // Add install ID and site unique ID. $install_data['id'] = $install->id; $install_data['uid'] = $uid; $installs_data[] = $install_data; } } } restore_current_blog(); if ( 0 < count( $installs_data ) && ( $is_common_diff_for_any_site || ! $only_diff ) ) { if ( ! $only_diff ) { $installs_data[] = $common; } else if ( ! empty( $common_diff_union ) ) { $installs_data[] = $common_diff_union; } } foreach ( $installs_data as &$data ) { $data = (object) $data; } return $installs_data; }
[ "private", "function", "get_installs_data_for_api", "(", "array", "$", "override", ",", "$", "only_diff", "=", "false", ",", "$", "include_plugins", "=", "true", ",", "$", "include_themes", "=", "true", ")", "{", "/**\r\n * @since 1.1.8 Also send plugin up...
Update installs details. @todo V1 of multiste network support doesn't support plugin and theme data sending. @author Vova Feldman (@svovaf) @since 2.0.0 @param string[] string $override @param bool $only_diff @param bool $include_plugins Since 1.1.8 by default include plugin changes. @param bool $include_themes Since 1.1.8 by default include plugin changes. @return array
[ "Update", "installs", "details", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8054-L8165
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_install_diff_for_api
private function get_install_diff_for_api( $site, $install, $override = array() ) { $diff = array(); $special = array(); $special_override = false; foreach ( $site as $p => $v ) { if ( property_exists( $install, $p ) ) { if ( ( is_bool( $install->{$p} ) || ! empty( $install->{$p} ) ) && $install->{$p} != $v ) { $install->{$p} = $v; $diff[ $p ] = $v; } } else { $special[ $p ] = $v; if ( isset( $override[ $p ] ) || 'plugins' === $p || 'themes' === $p ) { $special_override = true; } } } if ( $special_override || 0 < count( $diff ) ) { // Add special params only if has at least one // standard param, or if explicitly requested to // override a special param or a param which is not exist // in the install object. $diff = array_merge( $diff, $special ); } return $diff; }
php
private function get_install_diff_for_api( $site, $install, $override = array() ) { $diff = array(); $special = array(); $special_override = false; foreach ( $site as $p => $v ) { if ( property_exists( $install, $p ) ) { if ( ( is_bool( $install->{$p} ) || ! empty( $install->{$p} ) ) && $install->{$p} != $v ) { $install->{$p} = $v; $diff[ $p ] = $v; } } else { $special[ $p ] = $v; if ( isset( $override[ $p ] ) || 'plugins' === $p || 'themes' === $p ) { $special_override = true; } } } if ( $special_override || 0 < count( $diff ) ) { // Add special params only if has at least one // standard param, or if explicitly requested to // override a special param or a param which is not exist // in the install object. $diff = array_merge( $diff, $special ); } return $diff; }
[ "private", "function", "get_install_diff_for_api", "(", "$", "site", ",", "$", "install", ",", "$", "override", "=", "array", "(", ")", ")", "{", "$", "diff", "=", "array", "(", ")", ";", "$", "special", "=", "array", "(", ")", ";", "$", "special_ove...
Compare site actual data to the stored install data and return the differences for an API data sync. @author Vova Feldman (@svovaf) @since 2.0.0 @param array $site @param FS_Site $install @param string[] string $override @return array
[ "Compare", "site", "actual", "data", "to", "the", "stored", "install", "data", "and", "return", "the", "differences", "for", "an", "API", "data", "sync", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8179-L8213
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.send_installs_update
private function send_installs_update( $override = array(), $flush = false ) { $this->_logger->entrance(); $installs_data = $this->get_installs_data_for_api( $override, ! $flush ); $keepalive_only_update = false; if ( empty( $installs_data ) ) { /** * Pass `true` to use the network level storage since the update is for many installs. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ $keepalive_only_update = $this->should_send_keepalive_update( true ); if ( ! $keepalive_only_update ) { /** * There are no updates to send including keepalive. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ return false; } } if ( ! $keepalive_only_update ) { // Update last install sync timestamp if there were actual updates sent (i.e., not a keepalive-only call). $this->set_cron_execution_timestamp( 'install_sync' ); } /** * Pass `true` to use the network level storage since the update is for many installs. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ $this->set_keepalive_timestamp( true ); // Send updated values to FS. $result = $this->get_api_user_scope()->call( "/plugins/{$this->_plugin->id}/installs.json", 'put', $installs_data ); if ( ! $keepalive_only_update && $this->is_api_result_object( $result, 'installs' ) ) { // I successfully sent installs update (there was an actual update sent and it's not just a keepalive-only call), clear scheduled sync if exist. $this->clear_install_sync_cron(); } return $result; }
php
private function send_installs_update( $override = array(), $flush = false ) { $this->_logger->entrance(); $installs_data = $this->get_installs_data_for_api( $override, ! $flush ); $keepalive_only_update = false; if ( empty( $installs_data ) ) { /** * Pass `true` to use the network level storage since the update is for many installs. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ $keepalive_only_update = $this->should_send_keepalive_update( true ); if ( ! $keepalive_only_update ) { /** * There are no updates to send including keepalive. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ return false; } } if ( ! $keepalive_only_update ) { // Update last install sync timestamp if there were actual updates sent (i.e., not a keepalive-only call). $this->set_cron_execution_timestamp( 'install_sync' ); } /** * Pass `true` to use the network level storage since the update is for many installs. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ $this->set_keepalive_timestamp( true ); // Send updated values to FS. $result = $this->get_api_user_scope()->call( "/plugins/{$this->_plugin->id}/installs.json", 'put', $installs_data ); if ( ! $keepalive_only_update && $this->is_api_result_object( $result, 'installs' ) ) { // I successfully sent installs update (there was an actual update sent and it's not just a keepalive-only call), clear scheduled sync if exist. $this->clear_install_sync_cron(); } return $result; }
[ "private", "function", "send_installs_update", "(", "$", "override", "=", "array", "(", ")", ",", "$", "flush", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "installs_data", "=", "$", "this", "->", "get_in...
Update installs only if changed. @author Vova Feldman (@svovaf) @since 2.0.0 @param string[] string $override @param bool $flush @return false|object|string
[ "Update", "installs", "only", "if", "changed", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8300-L8348
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.track_event
public function track_event( $name, $properties = array(), $process_at = false, $once = false ) { $this->_logger->entrance( http_build_query( array( 'name' => $name, 'once' => $once ) ) ); if ( ! $this->is_registered() ) { return false; } $event = array( 'type' => $name ); if ( is_numeric( $process_at ) && $process_at > time() ) { $event['process_at'] = $process_at; } if ( $once ) { $event['once'] = true; } if ( ! empty( $properties ) ) { // Verify associative array values are primitive. foreach ( $properties as $k => $v ) { if ( ! is_scalar( $v ) ) { throw new Freemius_InvalidArgumentException( 'The $properties argument must be an associative key/value array with primitive values only.' ); } } $event['properties'] = $properties; } $result = $this->get_api_site_scope()->call( 'events.json', 'post', $event ); return $this->is_api_error( $result ) ? false : $result; }
php
public function track_event( $name, $properties = array(), $process_at = false, $once = false ) { $this->_logger->entrance( http_build_query( array( 'name' => $name, 'once' => $once ) ) ); if ( ! $this->is_registered() ) { return false; } $event = array( 'type' => $name ); if ( is_numeric( $process_at ) && $process_at > time() ) { $event['process_at'] = $process_at; } if ( $once ) { $event['once'] = true; } if ( ! empty( $properties ) ) { // Verify associative array values are primitive. foreach ( $properties as $k => $v ) { if ( ! is_scalar( $v ) ) { throw new Freemius_InvalidArgumentException( 'The $properties argument must be an associative key/value array with primitive values only.' ); } } $event['properties'] = $properties; } $result = $this->get_api_site_scope()->call( 'events.json', 'post', $event ); return $this->is_api_error( $result ) ? false : $result; }
[ "public", "function", "track_event", "(", "$", "name", ",", "$", "properties", "=", "array", "(", ")", ",", "$", "process_at", "=", "false", ",", "$", "once", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "http_build_quer...
Track install's custom event. IMPORTANT: Custom event tracking is currently only supported for specific clients. If you are not one of them, please don't use this method. If you will, the API will simply ignore your request based on the plugin ID. Need custom tracking for your plugin or theme? If you are interested in custom event tracking please contact yo@freemius.com for further details. @author Vova Feldman (@svovaf) @since 1.2.1 @param string $name Event name. @param array $properties Associative key/value array with primitive values only @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s. @param bool $once If true, event will be tracked only once. IMPORTANT: Still trigger the API call. @return object|false Event data or FALSE on failure. @throws \Freemius_InvalidArgumentException
[ "Track", "install", "s", "custom", "event", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8458-L8491
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.track_event_once
public function track_event_once( $name, $properties = array(), $process_at = false ) { return $this->track_event( $name, $properties, $process_at, true ); }
php
public function track_event_once( $name, $properties = array(), $process_at = false ) { return $this->track_event( $name, $properties, $process_at, true ); }
[ "public", "function", "track_event_once", "(", "$", "name", ",", "$", "properties", "=", "array", "(", ")", ",", "$", "process_at", "=", "false", ")", "{", "return", "$", "this", "->", "track_event", "(", "$", "name", ",", "$", "properties", ",", "$", ...
Track install's custom event only once, but it still triggers the API call. IMPORTANT: Custom event tracking is currently only supported for specific clients. If you are not one of them, please don't use this method. If you will, the API will simply ignore your request based on the plugin ID. Need custom tracking for your plugin or theme? If you are interested in custom event tracking please contact yo@freemius.com for further details. @author Vova Feldman (@svovaf) @since 1.2.1 @param string $name Event name. @param array $properties Associative key/value array with primitive values only @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s. @return object|false Event data or FALSE on failure. @throws \Freemius_InvalidArgumentException @user Freemius::track_event()
[ "Track", "install", "s", "custom", "event", "only", "once", "but", "it", "still", "triggers", "the", "API", "call", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8518-L8520
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._uninstall_plugin_event
function _uninstall_plugin_event( $check_user = true ) { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( $check_user && ! current_user_can( 'activate_plugins' ) ) { return; } $params = array(); $uninstall_reason = null; if ( isset( $this->_storage->uninstall_reason ) ) { $uninstall_reason = $this->_storage->uninstall_reason; $params['reason_id'] = $uninstall_reason->id; $params['reason_info'] = $uninstall_reason->info; } if ( ! $this->is_registered() ) { // Send anonymous uninstall event only if user submitted a feedback. if ( isset( $uninstall_reason ) ) { if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) { $this->opt_in( false, false, false, false, true ); } else { $params['uid'] = $this->get_anonymous_id(); $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params ); } } } else { $params = array_merge( $params, array( 'is_active' => false, 'is_uninstalled' => true, ) ); if ( $this->_is_network_active ) { // Send uninstall event. $this->send_installs_update( $params ); } else { // Send uninstall event. $this->send_install_update( $params ); } } // @todo Decide if we want to delete plugin information from db. }
php
function _uninstall_plugin_event( $check_user = true ) { $this->_logger->entrance( 'slug = ' . $this->_slug ); if ( $check_user && ! current_user_can( 'activate_plugins' ) ) { return; } $params = array(); $uninstall_reason = null; if ( isset( $this->_storage->uninstall_reason ) ) { $uninstall_reason = $this->_storage->uninstall_reason; $params['reason_id'] = $uninstall_reason->id; $params['reason_info'] = $uninstall_reason->info; } if ( ! $this->is_registered() ) { // Send anonymous uninstall event only if user submitted a feedback. if ( isset( $uninstall_reason ) ) { if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) { $this->opt_in( false, false, false, false, true ); } else { $params['uid'] = $this->get_anonymous_id(); $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params ); } } } else { $params = array_merge( $params, array( 'is_active' => false, 'is_uninstalled' => true, ) ); if ( $this->_is_network_active ) { // Send uninstall event. $this->send_installs_update( $params ); } else { // Send uninstall event. $this->send_install_update( $params ); } } // @todo Decide if we want to delete plugin information from db. }
[ "function", "_uninstall_plugin_event", "(", "$", "check_user", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "'slug = '", ".", "$", "this", "->", "_slug", ")", ";", "if", "(", "$", "check_user", "&&", "!", "current_user_can", ...
Plugin uninstall hook. @author Vova Feldman (@svovaf) @since 1.0.1 @param bool $check_user Enforce checking if user have plugins activation privileges.
[ "Plugin", "uninstall", "hook", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8530-L8571
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._uninstall_plugin_hook
public static function _uninstall_plugin_hook() { self::_load_required_static(); self::$_static_logger->entrance(); if ( ! current_user_can( 'activate_plugins' ) ) { return; } $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) ); self::$_static_logger->info( 'plugin = ' . $plugin_file ); define( 'WP_FS__UNINSTALL_MODE', true ); $fs = self::get_instance_by_file( $plugin_file ); if ( is_object( $fs ) ) { self::require_plugin_essentials(); if ( is_plugin_active( $fs->_free_plugin_basename ) || is_plugin_active( $fs->premium_plugin_basename() ) ) { // Deleting Free or Premium plugin version while the other version still installed. return; } $fs->_uninstall_plugin_event(); $fs->do_action( 'after_uninstall' ); } }
php
public static function _uninstall_plugin_hook() { self::_load_required_static(); self::$_static_logger->entrance(); if ( ! current_user_can( 'activate_plugins' ) ) { return; } $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) ); self::$_static_logger->info( 'plugin = ' . $plugin_file ); define( 'WP_FS__UNINSTALL_MODE', true ); $fs = self::get_instance_by_file( $plugin_file ); if ( is_object( $fs ) ) { self::require_plugin_essentials(); if ( is_plugin_active( $fs->_free_plugin_basename ) || is_plugin_active( $fs->premium_plugin_basename() ) ) { // Deleting Free or Premium plugin version while the other version still installed. return; } $fs->_uninstall_plugin_event(); $fs->do_action( 'after_uninstall' ); } }
[ "public", "static", "function", "_uninstall_plugin_hook", "(", ")", "{", "self", "::", "_load_required_static", "(", ")", ";", "self", "::", "$", "_static_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "current_user_can", "(", "'activate_plugins'", ...
Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking. @author Vova Feldman (@svovaf) @since 1.0.2
[ "Uninstall", "plugin", "hook", ".", "Called", "only", "when", "connected", "his", "account", "with", "Freemius", "for", "active", "sites", "tracking", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8634-L8665
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_plugin_data
function get_plugin_data() { if ( ! isset( $this->_plugin_data ) ) { self::require_plugin_essentials(); if ( $this->is_plugin() ) { /** * @author Vova Feldman (@svovaf) * @since 1.2.0 When using get_plugin_data() do NOT translate plugin data. * * @link https://github.com/Freemius/wordpress-sdk/issues/77 */ $plugin_data = get_plugin_data( $this->_plugin_main_file_path, false, false ); } else { $theme_data = wp_get_theme(); if ( $this->_plugin_basename !== $theme_data->get_stylesheet() && is_child_theme() ) { $parent_theme = $theme_data->parent(); if ( ( $parent_theme instanceof WP_Theme ) && $this->_plugin_basename === $parent_theme->get_stylesheet() ) { $theme_data = $parent_theme; } } $plugin_data = array( 'Name' => $theme_data->get( 'Name' ), 'Version' => $theme_data->get( 'Version' ), 'Author' => $theme_data->get( 'Author' ), 'Description' => $theme_data->get( 'Description' ), 'PluginURI' => $theme_data->get( 'ThemeURI' ), ); } $this->_plugin_data = $plugin_data; } return $this->_plugin_data; }
php
function get_plugin_data() { if ( ! isset( $this->_plugin_data ) ) { self::require_plugin_essentials(); if ( $this->is_plugin() ) { /** * @author Vova Feldman (@svovaf) * @since 1.2.0 When using get_plugin_data() do NOT translate plugin data. * * @link https://github.com/Freemius/wordpress-sdk/issues/77 */ $plugin_data = get_plugin_data( $this->_plugin_main_file_path, false, false ); } else { $theme_data = wp_get_theme(); if ( $this->_plugin_basename !== $theme_data->get_stylesheet() && is_child_theme() ) { $parent_theme = $theme_data->parent(); if ( ( $parent_theme instanceof WP_Theme ) && $this->_plugin_basename === $parent_theme->get_stylesheet() ) { $theme_data = $parent_theme; } } $plugin_data = array( 'Name' => $theme_data->get( 'Name' ), 'Version' => $theme_data->get( 'Version' ), 'Author' => $theme_data->get( 'Author' ), 'Description' => $theme_data->get( 'Description' ), 'PluginURI' => $theme_data->get( 'ThemeURI' ), ); } $this->_plugin_data = $plugin_data; } return $this->_plugin_data; }
[ "function", "get_plugin_data", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_plugin_data", ")", ")", "{", "self", "::", "require_plugin_essentials", "(", ")", ";", "if", "(", "$", "this", "->", "is_plugin", "(", ")", ")", "{", "/*...
Return plugin data. @author Vova Feldman (@svovaf) @since 1.0.1 @return array
[ "Return", "plugin", "data", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L8705-L8745
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.find_slug_by_basename
private static function find_slug_by_basename( $plugin_base_name ) { $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() ); if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) { return false; } return $file_slug_map[ $plugin_base_name ]; }
php
private static function find_slug_by_basename( $plugin_base_name ) { $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() ); if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) { return false; } return $file_slug_map[ $plugin_base_name ]; }
[ "private", "static", "function", "find_slug_by_basename", "(", "$", "plugin_base_name", ")", "{", "$", "file_slug_map", "=", "self", "::", "$", "_accounts", "->", "get_option", "(", "'file_slug_map'", ",", "array", "(", ")", ")", ";", "if", "(", "!", "array"...
Find plugin's slug by plugin's basename. @author Vova Feldman (@svovaf) @since 1.0.9 @param string $plugin_base_name @return false|string
[ "Find", "plugin", "s", "slug", "by", "plugin", "s", "basename", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9015-L9023
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.store_file_slug_map
private function store_file_slug_map() { $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() ); if ( ! array( $file_slug_map ) ) { $file_slug_map = array(); } if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) || $file_slug_map[ $this->_plugin_basename ] !== $this->_slug ) { $file_slug_map[ $this->_plugin_basename ] = $this->_slug; self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true ); } }
php
private function store_file_slug_map() { $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() ); if ( ! array( $file_slug_map ) ) { $file_slug_map = array(); } if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) || $file_slug_map[ $this->_plugin_basename ] !== $this->_slug ) { $file_slug_map[ $this->_plugin_basename ] = $this->_slug; self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true ); } }
[ "private", "function", "store_file_slug_map", "(", ")", "{", "$", "file_slug_map", "=", "self", "::", "$", "_accounts", "->", "get_option", "(", "'file_slug_map'", ",", "array", "(", ")", ")", ";", "if", "(", "!", "array", "(", "$", "file_slug_map", ")", ...
Store the map between the plugin's basename to the slug. @author Vova Feldman (@svovaf) @since 1.0.9
[ "Store", "the", "map", "between", "the", "plugin", "s", "basename", "to", "the", "slug", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9031-L9044
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.link_license_2_user
private function link_license_2_user( $license_id, $user_id ) { $license_ids = $this->get_user_linked_license_ids( $user_id ); if ( in_array( $license_id, $license_ids ) ) { // License already linked. return; } $license_ids[] = $license_id; $this->set_user_linked_license_ids( $user_id, $license_ids ); }
php
private function link_license_2_user( $license_id, $user_id ) { $license_ids = $this->get_user_linked_license_ids( $user_id ); if ( in_array( $license_id, $license_ids ) ) { // License already linked. return; } $license_ids[] = $license_id; $this->set_user_linked_license_ids( $user_id, $license_ids ); }
[ "private", "function", "link_license_2_user", "(", "$", "license_id", ",", "$", "user_id", ")", "{", "$", "license_ids", "=", "$", "this", "->", "get_user_linked_license_ids", "(", "$", "user_id", ")", ";", "if", "(", "in_array", "(", "$", "license_id", ",",...
Link a specified license ID to a given user. @author Vova Feldman (@svovaf) @since 2.0.0 @param number $license_id @param number $user_id
[ "Link", "a", "specified", "license", "ID", "to", "a", "given", "user", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9290-L9301
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_addons
function get_addons( $flush = false ) { $this->_logger->entrance(); if ( ! $this->_has_addons ) { return false; } $addons = $this->sync_addons( $flush ); return ( ! is_array( $addons ) || empty( $addons ) ) ? false : $addons; }
php
function get_addons( $flush = false ) { $this->_logger->entrance(); if ( ! $this->_has_addons ) { return false; } $addons = $this->sync_addons( $flush ); return ( ! is_array( $addons ) || empty( $addons ) ) ? false : $addons; }
[ "function", "get_addons", "(", "$", "flush", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "_has_addons", ")", "{", "return", "false", ";", "}", "$", "addons", "=", "$", ...
Get plugin add-ons. @author Vova Feldman (@svovaf) @since 1.0.6 @since 1.1.7.3 If not yet loaded, fetch data from the API. @param bool $flush @return FS_Plugin[]|false
[ "Get", "plugin", "add", "-", "ons", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9437-L9449
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_super_admin
private static function is_super_admin( $user_id ) { $is_super_admin = false; $user = self::_get_user_by_id( $user_id ); if ( $user instanceof FS_User && ! empty( $user->email ) ) { self::require_pluggable_essentials(); $wp_user = get_user_by( 'email', $user->email ); if ( $wp_user instanceof WP_User ) { $super_admins = get_super_admins(); $is_super_admin = ( is_array( $super_admins ) && in_array( $wp_user->user_login, $super_admins ) ); } } return $is_super_admin; }
php
private static function is_super_admin( $user_id ) { $is_super_admin = false; $user = self::_get_user_by_id( $user_id ); if ( $user instanceof FS_User && ! empty( $user->email ) ) { self::require_pluggable_essentials(); $wp_user = get_user_by( 'email', $user->email ); if ( $wp_user instanceof WP_User ) { $super_admins = get_super_admins(); $is_super_admin = ( is_array( $super_admins ) && in_array( $wp_user->user_login, $super_admins ) ); } } return $is_super_admin; }
[ "private", "static", "function", "is_super_admin", "(", "$", "user_id", ")", "{", "$", "is_super_admin", "=", "false", ";", "$", "user", "=", "self", "::", "_get_user_by_id", "(", "$", "user_id", ")", ";", "if", "(", "$", "user", "instanceof", "FS_User", ...
Checks if a Freemius user_id is associated with a super-admin. @author Vova Feldman (@svovaf) @since 2.0.0 @param number $user_id @return bool
[ "Checks", "if", "a", "Freemius", "user_id", "is", "associated", "with", "a", "super", "-", "admin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9587-L9604
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_trial_utilized
function is_trial_utilized() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return false; } return $this->_site->is_trial_utilized(); }
php
function is_trial_utilized() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return false; } return $this->_site->is_trial_utilized(); }
[ "function", "is_trial_utilized", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "_site", ...
Check if trial already utilized. @since 1.0.9 @return bool
[ "Check", "if", "trial", "already", "utilized", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9728-L9736
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_paying
function is_paying() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return false; } if ( ! $this->has_paid_plan() ) { return false; } return ( ! $this->is_trial() && 'free' !== $this->get_plan_name() && $this->has_active_valid_license() ); }
php
function is_paying() { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return false; } if ( ! $this->has_paid_plan() ) { return false; } return ( ! $this->is_trial() && 'free' !== $this->get_plan_name() && $this->has_active_valid_license() ); }
[ "function", "is_paying", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "has_pa...
Check if the user has an activate, non-expired license on current plugin's install. @since 1.0.9 @return bool
[ "Check", "if", "the", "user", "has", "an", "activate", "non", "-", "expired", "license", "on", "current", "plugin", "s", "install", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9794-L9810
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._sync_plans
function _sync_plans() { $plans = $this->_fetch_plugin_plans(); if ( $this->is_array_instanceof( $plans, 'FS_Plugin_Plan' ) ) { $plans_map = array(); foreach ( $plans as $plan ) { $plans_map[ $plan->id ] = true; } $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs(); foreach ( $plans_ids_to_keep as $plan_id ) { if ( isset( $plans_map[ $plan_id ] ) ) { continue; } $missing_plan = self::_get_plan_by_id( $plan_id ); if ( is_object( $missing_plan ) ) { $plans[] = $missing_plan; } } $this->_plans = $plans; $this->_store_plans(); } $this->do_action( 'after_plans_sync', $plans ); return $this->_plans; }
php
function _sync_plans() { $plans = $this->_fetch_plugin_plans(); if ( $this->is_array_instanceof( $plans, 'FS_Plugin_Plan' ) ) { $plans_map = array(); foreach ( $plans as $plan ) { $plans_map[ $plan->id ] = true; } $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs(); foreach ( $plans_ids_to_keep as $plan_id ) { if ( isset( $plans_map[ $plan_id ] ) ) { continue; } $missing_plan = self::_get_plan_by_id( $plan_id ); if ( is_object( $missing_plan ) ) { $plans[] = $missing_plan; } } $this->_plans = $plans; $this->_store_plans(); } $this->do_action( 'after_plans_sync', $plans ); return $this->_plans; }
[ "function", "_sync_plans", "(", ")", "{", "$", "plans", "=", "$", "this", "->", "_fetch_plugin_plans", "(", ")", ";", "if", "(", "$", "this", "->", "is_array_instanceof", "(", "$", "plans", ",", "'FS_Plugin_Plan'", ")", ")", "{", "$", "plans_map", "=", ...
Sync local plugin plans with remote server. IMPORTANT: If for some reason a site is associated with deleted plan, we'll preserve the plan's information and append it as the last plan. This means that if plan is deleted, the is_plan() method will ALWAYS return true for any given argument (it becomes the most inclusive plan). @author Vova Feldman (@svovaf) @since 1.0.5 @return FS_Plugin_Plan[]|object
[ "Sync", "local", "plugin", "plans", "with", "remote", "server", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9917-L9947
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.sync_plan_if_not_exist
private function sync_plan_if_not_exist( $plan_id ) { $plan = self::_get_plan_by_id( $plan_id ); if ( is_object( $plan ) ) { // Plan already exists. return $plan; } $plan = $this->fetch_plan_by_id( $plan_id ); if ( $plan instanceof FS_Plugin_Plan ) { $this->_plans[] = $plan; $this->_store_plans(); return $plan; } return $plan; }
php
private function sync_plan_if_not_exist( $plan_id ) { $plan = self::_get_plan_by_id( $plan_id ); if ( is_object( $plan ) ) { // Plan already exists. return $plan; } $plan = $this->fetch_plan_by_id( $plan_id ); if ( $plan instanceof FS_Plugin_Plan ) { $this->_plans[] = $plan; $this->_store_plans(); return $plan; } return $plan; }
[ "private", "function", "sync_plan_if_not_exist", "(", "$", "plan_id", ")", "{", "$", "plan", "=", "self", "::", "_get_plan_by_id", "(", "$", "plan_id", ")", ";", "if", "(", "is_object", "(", "$", "plan", ")", ")", "{", "// Plan already exists.\r", "return", ...
Check if specified plan exists locally. If not, fetch it and store it. @author Vova Feldman (@svovaf) @since 2.0.0 @param number $plan_id @return \FS_Plugin_Plan|object The plan entity or the API error object on failure.
[ "Check", "if", "specified", "plan", "exists", "locally", ".", "If", "not", "fetch", "it", "and", "store", "it", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9959-L9977
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.sync_license_if_not_exist
private function sync_license_if_not_exist( $license_id, $license_key ) { $license = $this->_get_license_by_id( $license_id ); if ( is_object( $license ) ) { // License already exists. return $license; } $license = $this->fetch_license_by_key( $license_id, $license_key ); if ( $license instanceof FS_Plugin_License ) { $this->_licenses[] = $license; $this->_license = $license; $this->_store_licenses(); return $license; } return $license; }
php
private function sync_license_if_not_exist( $license_id, $license_key ) { $license = $this->_get_license_by_id( $license_id ); if ( is_object( $license ) ) { // License already exists. return $license; } $license = $this->fetch_license_by_key( $license_id, $license_key ); if ( $license instanceof FS_Plugin_License ) { $this->_licenses[] = $license; $this->_license = $license; $this->_store_licenses(); return $license; } return $license; }
[ "private", "function", "sync_license_if_not_exist", "(", "$", "license_id", ",", "$", "license_key", ")", "{", "$", "license", "=", "$", "this", "->", "_get_license_by_id", "(", "$", "license_id", ")", ";", "if", "(", "is_object", "(", "$", "license", ")", ...
Check if specified license exists locally. If not, fetch it and store it. @author Vova Feldman (@svovaf) @since 2.0.0 @param number $license_id @param string $license_key @return \FS_Plugin_Plan|object The plan entity or the API error object on failure.
[ "Check", "if", "specified", "license", "exists", "locally", ".", "If", "not", "fetch", "it", "and", "store", "it", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L9990-L10009
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_plans_ids_associated_with_installs
private function get_plans_ids_associated_with_installs() { if ( ! $this->_is_network_active ) { if ( ! is_object( $this->_site ) || ! FS_Plugin_Plan::is_valid_id( $this->_site->plan_id ) ) { return array(); } return array( $this->_site->plan_id ); } $plan_ids = array(); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( ! is_object( $install ) || ! FS_Plugin_Plan::is_valid_id( $install->plan_id ) ) { continue; } $plan_ids[ $install->plan_id ] = true; } return array_keys( $plan_ids ); }
php
private function get_plans_ids_associated_with_installs() { if ( ! $this->_is_network_active ) { if ( ! is_object( $this->_site ) || ! FS_Plugin_Plan::is_valid_id( $this->_site->plan_id ) ) { return array(); } return array( $this->_site->plan_id ); } $plan_ids = array(); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( ! is_object( $install ) || ! FS_Plugin_Plan::is_valid_id( $install->plan_id ) ) { continue; } $plan_ids[ $install->plan_id ] = true; } return array_keys( $plan_ids ); }
[ "private", "function", "get_plans_ids_associated_with_installs", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_site", ")", "||", "!", "FS_Plugin_Plan", "::", "is_valid...
Get a collection of unique plan IDs that are associated with any installs in the network. @author Leo Fajardo (@leorw) @since 2.0.0 @return number[]
[ "Get", "a", "collection", "of", "unique", "plan", "IDs", "that", "are", "associated", "with", "any", "installs", "in", "the", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10019-L10046
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_license_ids_associated_with_installs
private function get_license_ids_associated_with_installs() { if ( ! $this->_is_network_active ) { if ( ! is_object( $this->_site ) || ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) { return array(); } return array( $this->_site->license_id ); } $license_ids = array(); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( ! is_object( $install ) || ! FS_Plugin_License::is_valid_id( $install->license_id ) ) { continue; } $license_ids[ $install->license_id ] = true; } return array_keys( $license_ids ); }
php
private function get_license_ids_associated_with_installs() { if ( ! $this->_is_network_active ) { if ( ! is_object( $this->_site ) || ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) { return array(); } return array( $this->_site->license_id ); } $license_ids = array(); $sites = self::get_sites(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( ! is_object( $install ) || ! FS_Plugin_License::is_valid_id( $install->license_id ) ) { continue; } $license_ids[ $install->license_id ] = true; } return array_keys( $license_ids ); }
[ "private", "function", "get_license_ids_associated_with_installs", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_site", ")", "||", "!", "FS_Plugin_License", "::", "is_...
Get a collection of unique license IDs that are associated with any installs in the network. @author Leo Fajardo (@leorw) @since 2.0.0 @return number[]
[ "Get", "a", "collection", "of", "unique", "license", "IDs", "that", "are", "associated", "with", "any", "installs", "in", "the", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10056-L10083
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.sync_site_license
private function sync_site_license() { $api = $this->get_api_user_scope(); $result = $api->get( "/licenses/{$this->_license->id}.json?license_key=" . urlencode( $this->_license->secret_key ), true ); if ( ! $this->is_api_result_entity( $result ) ) { return $result; } $license = $this->_update_site_license( new FS_Plugin_License( $result ) ); $this->_store_licenses(); return $license; }
php
private function sync_site_license() { $api = $this->get_api_user_scope(); $result = $api->get( "/licenses/{$this->_license->id}.json?license_key=" . urlencode( $this->_license->secret_key ), true ); if ( ! $this->is_api_result_entity( $result ) ) { return $result; } $license = $this->_update_site_license( new FS_Plugin_License( $result ) ); $this->_store_licenses(); return $license; }
[ "private", "function", "sync_site_license", "(", ")", "{", "$", "api", "=", "$", "this", "->", "get_api_user_scope", "(", ")", ";", "$", "result", "=", "$", "api", "->", "get", "(", "\"/licenses/{$this->_license->id}.json?license_key=\"", ".", "urlencode", "(", ...
Synchronize the site's context license by fetching the license form the API and updating the local data with it. @author Vova Feldman (@svovaf) @since 2.0.0 @return \FS_Plugin_License|mixed
[ "Synchronize", "the", "site", "s", "context", "license", "by", "fetching", "the", "license", "form", "the", "API", "and", "updating", "the", "local", "data", "with", "it", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10329-L10342
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_user_licenses
private function get_user_licenses( $user_id ) { $all_licenses = self::get_all_licenses( $this->_module_id ); if ( empty( $all_licenses ) ) { return array(); } $user_license_ids = $this->get_user_linked_license_ids( $user_id ); if ( empty( $user_license_ids ) ) { return array(); } $licenses = array(); foreach ( $all_licenses as $license ) { if ( in_array( $license->id, $user_license_ids ) ) { $licenses[] = $license; } } return $licenses; }
php
private function get_user_licenses( $user_id ) { $all_licenses = self::get_all_licenses( $this->_module_id ); if ( empty( $all_licenses ) ) { return array(); } $user_license_ids = $this->get_user_linked_license_ids( $user_id ); if ( empty( $user_license_ids ) ) { return array(); } $licenses = array(); foreach ( $all_licenses as $license ) { if ( in_array( $license->id, $user_license_ids ) ) { $licenses[] = $license; } } return $licenses; }
[ "private", "function", "get_user_licenses", "(", "$", "user_id", ")", "{", "$", "all_licenses", "=", "self", "::", "get_all_licenses", "(", "$", "this", "->", "_module_id", ")", ";", "if", "(", "empty", "(", "$", "all_licenses", ")", ")", "{", "return", ...
Get all user's available licenses for the current module. @author Vova Feldman (@svovaf) @since 2.0.0 @param number $user_id @return FS_Plugin_License[]
[ "Get", "all", "user", "s", "available", "licenses", "for", "the", "current", "module", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10354-L10373
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_license_network_active
private function is_license_network_active( $except_blog_id = 0 ) { $this->_logger->entrance(); if ( ! is_object( $this->_license ) ) { return false; } $sites = self::get_sites(); if ( $this->_license->total_activations() < ( count( $sites ) - 1 ) ) { // There are more sites than the number of activations, so license cannot be network activated. return false; } foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); if ( $except_blog_id == $blog_id ) { // Skip excluded blog. continue; } $install = $this->get_install_by_blog_id( $blog_id ); if ( is_object( $install ) && $install->license_id != $this->_license->id ) { return false; } } return true; }
php
private function is_license_network_active( $except_blog_id = 0 ) { $this->_logger->entrance(); if ( ! is_object( $this->_license ) ) { return false; } $sites = self::get_sites(); if ( $this->_license->total_activations() < ( count( $sites ) - 1 ) ) { // There are more sites than the number of activations, so license cannot be network activated. return false; } foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); if ( $except_blog_id == $blog_id ) { // Skip excluded blog. continue; } $install = $this->get_install_by_blog_id( $blog_id ); if ( is_object( $install ) && $install->license_id != $this->_license->id ) { return false; } } return true; }
[ "private", "function", "is_license_network_active", "(", "$", "except_blog_id", "=", "0", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "is_object", "(", "$", "this", "->", "_license", ")", ")", "{", "return", ...
Checks if the context license is network activated except on the given blog ID. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $except_blog_id @return bool
[ "Checks", "if", "the", "context", "license", "is", "network", "activated", "except", "on", "the", "given", "blog", "ID", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10385-L10415
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.can_activate_license_on_network
private function can_activate_license_on_network( FS_Plugin_License $license ) { $sites = self::get_sites(); $production_count = 0; $localhost_count = 0; $installs_without_license = array(); $disconnected_site_ids = array(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( is_object( $install ) ) { if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) { // License already activated on the install. continue; } $url = $install->url; $installs_without_license[ $blog_id ] = $install; } else { $url = is_object( $site ) ? $site->siteurl : get_site_url( $blog_id ); $disconnected_site_ids[] = $blog_id; } if ( FS_Site::is_localhost_by_address( $url ) ) { $localhost_count ++; } else { $production_count ++; } } if ( ! $license->can_activate_bulk( $production_count, $localhost_count ) ) { return false; } return array( 'installs' => $installs_without_license, 'sites' => $disconnected_site_ids, 'production_count' => $production_count, 'localhost_count' => $localhost_count, ); }
php
private function can_activate_license_on_network( FS_Plugin_License $license ) { $sites = self::get_sites(); $production_count = 0; $localhost_count = 0; $installs_without_license = array(); $disconnected_site_ids = array(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $install = $this->get_install_by_blog_id( $blog_id ); if ( is_object( $install ) ) { if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) { // License already activated on the install. continue; } $url = $install->url; $installs_without_license[ $blog_id ] = $install; } else { $url = is_object( $site ) ? $site->siteurl : get_site_url( $blog_id ); $disconnected_site_ids[] = $blog_id; } if ( FS_Site::is_localhost_by_address( $url ) ) { $localhost_count ++; } else { $production_count ++; } } if ( ! $license->can_activate_bulk( $production_count, $localhost_count ) ) { return false; } return array( 'installs' => $installs_without_license, 'sites' => $disconnected_site_ids, 'production_count' => $production_count, 'localhost_count' => $localhost_count, ); }
[ "private", "function", "can_activate_license_on_network", "(", "FS_Plugin_License", "$", "license", ")", "{", "$", "sites", "=", "self", "::", "get_sites", "(", ")", ";", "$", "production_count", "=", "0", ";", "$", "localhost_count", "=", "0", ";", "$", "in...
Checks if the given license can be activated on the whole network. @author Vova Feldman (@svovaf) @since 2.0.0 @param \FS_Plugin_License $license @return false|array { @type array[int]FS_Site $installs Blog ID to install map. @type int[] $sites Non-connected blog IDs. @type int $production_count Production sites count. @type int $localhost_count Production sites count. }
[ "Checks", "if", "the", "given", "license", "can", "be", "activated", "on", "the", "whole", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10475-L10522
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.activate_license_on_many_installs
private function activate_license_on_many_installs( FS_User $user, $license_key, array $blog_2_install_map ) { $params = array( array( 'license_key' => $this->apply_filters( 'license_key', $license_key ) ) ); $install_2_blog_map = array(); foreach ( $blog_2_install_map as $blog_id => $install ) { $params[] = array( 'id' => $install->id ); $install_2_blog_map[ $install->id ] = $blog_id; } $result = $this->get_api_user_scope_by_user( $user )->call( "plugins/{$this->_plugin->id}/installs.json", 'PUT', $params ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { return $result; } foreach ( $result->installs as $r_install ) { $install = new FS_Site( $r_install ); $install->is_disconnected = false; // Update install. $this->_store_site( true, $install_2_blog_map[ $r_install->id ], $install ); } return true; }
php
private function activate_license_on_many_installs( FS_User $user, $license_key, array $blog_2_install_map ) { $params = array( array( 'license_key' => $this->apply_filters( 'license_key', $license_key ) ) ); $install_2_blog_map = array(); foreach ( $blog_2_install_map as $blog_id => $install ) { $params[] = array( 'id' => $install->id ); $install_2_blog_map[ $install->id ] = $blog_id; } $result = $this->get_api_user_scope_by_user( $user )->call( "plugins/{$this->_plugin->id}/installs.json", 'PUT', $params ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { return $result; } foreach ( $result->installs as $r_install ) { $install = new FS_Site( $r_install ); $install->is_disconnected = false; // Update install. $this->_store_site( true, $install_2_blog_map[ $r_install->id ], $install ); } return true; }
[ "private", "function", "activate_license_on_many_installs", "(", "FS_User", "$", "user", ",", "$", "license_key", ",", "array", "$", "blog_2_install_map", ")", "{", "$", "params", "=", "array", "(", "array", "(", "'license_key'", "=>", "$", "this", "->", "appl...
Activate a given license on a collection of installs. @author Vova Feldman (@svovaf) @since 2.0.0 @param \FS_User $user @param string $license_key @param array $blog_2_install_map { @key int Blog ID. @value FS_Site Blog's associated install. } @return mixed|true
[ "Activate", "a", "given", "license", "on", "a", "collection", "of", "installs", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10539-L10578
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._update_site_license
function _update_site_license( $new_license ) { $this->_logger->entrance(); $this->_license = $new_license; if ( ! is_object( $new_license ) ) { $this->_site->license_id = null; $this->_sync_site_subscription( null ); return $this->_license; } $this->_site->license_id = $this->_license->id; if ( ! is_array( $this->_licenses ) ) { $this->_licenses = array(); } $is_license_found = false; for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) { if ( $new_license->id == $this->_licenses[ $i ]->id ) { $this->_licenses[ $i ] = $new_license; $is_license_found = true; break; } } // If new license just append. if ( ! $is_license_found ) { $this->_licenses[] = $new_license; } $this->_sync_site_subscription( $new_license ); return $this->_license; }
php
function _update_site_license( $new_license ) { $this->_logger->entrance(); $this->_license = $new_license; if ( ! is_object( $new_license ) ) { $this->_site->license_id = null; $this->_sync_site_subscription( null ); return $this->_license; } $this->_site->license_id = $this->_license->id; if ( ! is_array( $this->_licenses ) ) { $this->_licenses = array(); } $is_license_found = false; for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) { if ( $new_license->id == $this->_licenses[ $i ]->id ) { $this->_licenses[ $i ] = $new_license; $is_license_found = true; break; } } // If new license just append. if ( ! $is_license_found ) { $this->_licenses[] = $new_license; } $this->_sync_site_subscription( $new_license ); return $this->_license; }
[ "function", "_update_site_license", "(", "$", "new_license", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "_license", "=", "$", "new_license", ";", "if", "(", "!", "is_object", "(", "$", "new_license", ")", ...
Sync site's license with user licenses. @author Vova Feldman (@svovaf) @since 1.0.6 @param FS_Plugin_License|null $new_license @return FS_Plugin_License|null
[ "Sync", "site", "s", "license", "with", "user", "licenses", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10658-L10694
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._sync_site_subscription
private function _sync_site_subscription( $license ) { if ( ! is_object( $license ) ) { $this->delete_unused_subscriptions(); return false; } // Load subscription details if not lifetime. $subscription = $license->is_lifetime() ? false : $this->_fetch_site_license_subscription(); if ( is_object( $subscription ) && ! isset( $subscription->error ) ) { $this->store_subscription( $subscription ); } else { $this->delete_unused_subscriptions(); } return $subscription; }
php
private function _sync_site_subscription( $license ) { if ( ! is_object( $license ) ) { $this->delete_unused_subscriptions(); return false; } // Load subscription details if not lifetime. $subscription = $license->is_lifetime() ? false : $this->_fetch_site_license_subscription(); if ( is_object( $subscription ) && ! isset( $subscription->error ) ) { $this->store_subscription( $subscription ); } else { $this->delete_unused_subscriptions(); } return $subscription; }
[ "private", "function", "_sync_site_subscription", "(", "$", "license", ")", "{", "if", "(", "!", "is_object", "(", "$", "license", ")", ")", "{", "$", "this", "->", "delete_unused_subscriptions", "(", ")", ";", "return", "false", ";", "}", "// Load subscript...
Sync site's subscription. @author Vova Feldman (@svovaf) @since 1.0.9 @param FS_Plugin_License|null $license @return bool|\FS_Subscription
[ "Sync", "site", "s", "subscription", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10706-L10725
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_single_plan
function is_single_plan() { $this->_logger->entrance(); if ( ! $this->is_registered() || ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) { return true; } return ( 1 === count( $this->_plans ) ); }
php
function is_single_plan() { $this->_logger->entrance(); if ( ! $this->is_registered() || ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) { return true; } return ( 1 === count( $this->_plans ) ); }
[ "function", "is_single_plan", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", "||", "!", "is_array", "(", "$", "this", "->", "_plans", ")", "||", "0", "==="...
Check if module has only one plan. @author Vova Feldman (@svovaf) @since 1.2.1.7 @return bool
[ "Check", "if", "module", "has", "only", "one", "plan", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10894-L10905
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_trial_plan
function is_trial_plan( $plan, $exact = false ) { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return false; } if ( ! $this->is_trial() ) { return false; } $trial_plan = $this->get_trial_plan(); if ( $trial_plan->name === $plan ) { // Exact plan. return true; } else if ( $exact ) { // Required exact, but plans are different. return false; } $current_plan_order = - 1; $required_plan_order = - 1; for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) { if ( $plan === $this->_plans[ $i ]->name ) { $required_plan_order = $i; } else if ( $trial_plan->name === $this->_plans[ $i ]->name ) { $current_plan_order = $i; } } return ( $current_plan_order > $required_plan_order ); }
php
function is_trial_plan( $plan, $exact = false ) { $this->_logger->entrance(); if ( ! $this->is_registered() ) { return false; } if ( ! $this->is_trial() ) { return false; } $trial_plan = $this->get_trial_plan(); if ( $trial_plan->name === $plan ) { // Exact plan. return true; } else if ( $exact ) { // Required exact, but plans are different. return false; } $current_plan_order = - 1; $required_plan_order = - 1; for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) { if ( $plan === $this->_plans[ $i ]->name ) { $required_plan_order = $i; } else if ( $trial_plan->name === $this->_plans[ $i ]->name ) { $current_plan_order = $i; } } return ( $current_plan_order > $required_plan_order ); }
[ "function", "is_trial_plan", "(", "$", "plan", ",", "$", "exact", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_registered", "(", ")", ")", "{", "return", "false", ";",...
Check if plan based on trial. If not in trial mode, should return false. @since 1.0.9 @param string $plan Plan name @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. @return bool
[ "Check", "if", "plan", "based", "on", "trial", ".", "If", "not", "in", "trial", "mode", "should", "return", "false", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L10917-L10949
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._maybe_add_subscription_cancellation_dialog_box
function _maybe_add_subscription_cancellation_dialog_box( $is_license_deactivation = false ) { if ( fs_is_network_admin() ) { // Subscription cancellation dialog box is currently not supported for multisite networks. return; } $license = $this->_get_license(); /** * If the installation is associated with a non-lifetime license, which is either a single-site or only activated on a single production site (or zero), and connected to an active subscription, suggest the customer to cancel the subscription upon deactivation. * * @author Leo Fajardo (@leorw) (Comment added by Vova Feldman @svovaf) * @since 2.2.1 */ if ( ! is_object( $license ) || $license->is_lifetime() || ( ! $license->is_single_site() && $license->activated > 1 ) ) { return; } /** * @var FS_Subscription $subscription */ $subscription = $this->_get_subscription( $license->id ); if ( ! is_object( $subscription ) || ! $subscription->is_active() ) { return; } $vars = array( 'id' => $this->_module_id, 'license' => $license, 'has_trial' => $this->is_paid_trial(), 'is_license_deactivation' => $is_license_deactivation, ); fs_require_template( 'forms/subscription-cancellation.php', $vars ); }
php
function _maybe_add_subscription_cancellation_dialog_box( $is_license_deactivation = false ) { if ( fs_is_network_admin() ) { // Subscription cancellation dialog box is currently not supported for multisite networks. return; } $license = $this->_get_license(); /** * If the installation is associated with a non-lifetime license, which is either a single-site or only activated on a single production site (or zero), and connected to an active subscription, suggest the customer to cancel the subscription upon deactivation. * * @author Leo Fajardo (@leorw) (Comment added by Vova Feldman @svovaf) * @since 2.2.1 */ if ( ! is_object( $license ) || $license->is_lifetime() || ( ! $license->is_single_site() && $license->activated > 1 ) ) { return; } /** * @var FS_Subscription $subscription */ $subscription = $this->_get_subscription( $license->id ); if ( ! is_object( $subscription ) || ! $subscription->is_active() ) { return; } $vars = array( 'id' => $this->_module_id, 'license' => $license, 'has_trial' => $this->is_paid_trial(), 'is_license_deactivation' => $is_license_deactivation, ); fs_require_template( 'forms/subscription-cancellation.php', $vars ); }
[ "function", "_maybe_add_subscription_cancellation_dialog_box", "(", "$", "is_license_deactivation", "=", "false", ")", "{", "if", "(", "fs_is_network_admin", "(", ")", ")", "{", "// Subscription cancellation dialog box is currently not supported for multisite networks.\r", "return"...
Displays a subscription cancellation dialog box when the user clicks on the "Deactivate License" link on the "Account" page or deactivates a plugin and there's an active subscription that is either associated with a non-lifetime single-site license or non-lifetime multisite license that is only activated on a single production site. @author Leo Fajardo (@leorw) @since 2.2.1 @param bool $is_license_deactivation
[ "Displays", "a", "subscription", "cancellation", "dialog", "box", "when", "the", "user", "clicks", "on", "the", "Deactivate", "License", "link", "on", "the", "Account", "page", "or", "deactivates", "a", "plugin", "and", "there", "s", "an", "active", "subscript...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L11029-L11066
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._add_optout_dialog
function _add_optout_dialog() { if ( $this->is_theme() ) { $vars = null; fs_require_once_template( '/js/jquery.content-change.php', $vars ); } $vars = array( 'id' => $this->_module_id ); fs_require_template( 'forms/optout.php', $vars ); }
php
function _add_optout_dialog() { if ( $this->is_theme() ) { $vars = null; fs_require_once_template( '/js/jquery.content-change.php', $vars ); } $vars = array( 'id' => $this->_module_id ); fs_require_template( 'forms/optout.php', $vars ); }
[ "function", "_add_optout_dialog", "(", ")", "{", "if", "(", "$", "this", "->", "is_theme", "(", ")", ")", "{", "$", "vars", "=", "null", ";", "fs_require_once_template", "(", "'/js/jquery.content-change.php'", ",", "$", "vars", ")", ";", "}", "$", "vars", ...
Displays the opt-out dialog box when the user clicks on the "Opt Out" link on the "Plugins" page. @author Leo Fajardo (@leorw) @since 1.2.1.5
[ "Displays", "the", "opt", "-", "out", "dialog", "box", "when", "the", "user", "clicks", "on", "the", "Opt", "Out", "link", "on", "the", "Plugins", "page", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L11096-L11104
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._add_license_activation
function _add_license_activation() { if ( ! $this->is_user_admin() ) { // Only admins can activate a license. return; } if ( ! $this->has_paid_plan() ) { // Module doesn't have any paid plans. return; } if ( ! $this->is_premium() ) { // Only add license activation logic to the premium version. return; } // Add license activation link and AJAX request handler. if ( self::is_plugins_page() ) { /** * @since 1.2.0 Add license action link only on plugins page. */ $this->_add_license_action_link(); } // Add license activation AJAX callback. $this->add_ajax_action( 'activate_license', array( &$this, '_activate_license_ajax_action' ) ); // Add resend license AJAX callback. $this->add_ajax_action( 'resend_license_key', array( &$this, '_resend_license_key_ajax_action' ) ); }
php
function _add_license_activation() { if ( ! $this->is_user_admin() ) { // Only admins can activate a license. return; } if ( ! $this->has_paid_plan() ) { // Module doesn't have any paid plans. return; } if ( ! $this->is_premium() ) { // Only add license activation logic to the premium version. return; } // Add license activation link and AJAX request handler. if ( self::is_plugins_page() ) { /** * @since 1.2.0 Add license action link only on plugins page. */ $this->_add_license_action_link(); } // Add license activation AJAX callback. $this->add_ajax_action( 'activate_license', array( &$this, '_activate_license_ajax_action' ) ); // Add resend license AJAX callback. $this->add_ajax_action( 'resend_license_key', array( &$this, '_resend_license_key_ajax_action' ) ); }
[ "function", "_add_license_activation", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_user_admin", "(", ")", ")", "{", "// Only admins can activate a license.\r", "return", ";", "}", "if", "(", "!", "$", "this", "->", "has_paid_plan", "(", ")", ")", ...
Prepare page to include all required UI and logic for the license activation dialog. @author Vova Feldman (@svovaf) @since 1.2.0
[ "Prepare", "page", "to", "include", "all", "required", "UI", "and", "logic", "for", "the", "license", "activation", "dialog", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L11112-L11141
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._update_billing_ajax_action
function _update_billing_ajax_action() { $this->_logger->entrance(); $this->check_ajax_referer( 'update_billing' ); if ( ! $this->is_user_admin() ) { // Only for admins. self::shoot_ajax_failure(); } $billing = fs_request_get( 'billing' ); $api = $this->get_api_user_scope(); $result = $api->call( '/billing.json', 'put', array_merge( $billing, array( 'plugin_id' => $this->get_parent_id(), ) ) ); if ( ! $this->is_api_result_entity( $result ) ) { self::shoot_ajax_failure(); } // Purge cached billing. $this->get_api_user_scope()->purge_cache( 'billing.json' ); self::shoot_ajax_success(); }
php
function _update_billing_ajax_action() { $this->_logger->entrance(); $this->check_ajax_referer( 'update_billing' ); if ( ! $this->is_user_admin() ) { // Only for admins. self::shoot_ajax_failure(); } $billing = fs_request_get( 'billing' ); $api = $this->get_api_user_scope(); $result = $api->call( '/billing.json', 'put', array_merge( $billing, array( 'plugin_id' => $this->get_parent_id(), ) ) ); if ( ! $this->is_api_result_entity( $result ) ) { self::shoot_ajax_failure(); } // Purge cached billing. $this->get_api_user_scope()->purge_cache( 'billing.json' ); self::shoot_ajax_success(); }
[ "function", "_update_billing_ajax_action", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "check_ajax_referer", "(", "'update_billing'", ")", ";", "if", "(", "!", "$", "this", "->", "is_user_admin", "(", ")...
Billing update AJAX callback. @author Vova Feldman (@svovaf) @since 1.2.1.5
[ "Billing", "update", "AJAX", "callback", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L11467-L11492
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_current_page
static function get_current_page() { if ( ! isset( self::$_pagenow ) ) { global $pagenow; if ( empty( $pagenow ) && is_admin() && is_multisite() ) { /** * It appears that `$pagenow` is not yet initialized in some network admin pages when this method * is called, so initialize it here using some pieces of code from `wp-includes/vars.php`. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ if ( is_network_admin() ) { preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } else if ( is_user_admin() ) { preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } else { preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } $pagenow = $self_matches[1]; $pagenow = trim( $pagenow, '/' ); $pagenow = preg_replace( '#\?.*?$#', '', $pagenow ); if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { $pagenow = 'index.php'; } else { preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); $pagenow = strtolower( $self_matches[1] ); if ( '.php' !== substr($pagenow, -4, 4) ) $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) } } self::$_pagenow = $pagenow; if ( self::is_ajax() && 'admin-ajax.php' === $pagenow ) { $referer = fs_get_raw_referer(); if ( is_string( $referer ) ) { $parts = explode( '?', $referer ); self::$_pagenow = basename( $parts[0] ); } } } return self::$_pagenow; }
php
static function get_current_page() { if ( ! isset( self::$_pagenow ) ) { global $pagenow; if ( empty( $pagenow ) && is_admin() && is_multisite() ) { /** * It appears that `$pagenow` is not yet initialized in some network admin pages when this method * is called, so initialize it here using some pieces of code from `wp-includes/vars.php`. * * @author Leo Fajardo (@leorw) * @since 2.2.3 */ if ( is_network_admin() ) { preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } else if ( is_user_admin() ) { preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } else { preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } $pagenow = $self_matches[1]; $pagenow = trim( $pagenow, '/' ); $pagenow = preg_replace( '#\?.*?$#', '', $pagenow ); if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { $pagenow = 'index.php'; } else { preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); $pagenow = strtolower( $self_matches[1] ); if ( '.php' !== substr($pagenow, -4, 4) ) $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) } } self::$_pagenow = $pagenow; if ( self::is_ajax() && 'admin-ajax.php' === $pagenow ) { $referer = fs_get_raw_referer(); if ( is_string( $referer ) ) { $parts = explode( '?', $referer ); self::$_pagenow = basename( $parts[0] ); } } } return self::$_pagenow; }
[ "static", "function", "get_current_page", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_pagenow", ")", ")", "{", "global", "$", "pagenow", ";", "if", "(", "empty", "(", "$", "pagenow", ")", "&&", "is_admin", "(", ")", "&&", "is_...
Get current page or the referer if executing a WP AJAX request. @author Vova Feldman (@svovaf) @since 1.2.1.8 @return string
[ "Get", "current", "page", "or", "the", "referer", "if", "executing", "a", "WP", "AJAX", "request", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L11600-L11648
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.pricing_url
function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) { $this->_logger->entrance(); $params = array( 'billing_cycle' => $billing_cycle ); if ( $is_trial ) { $params['trial'] = 'true'; } if ( $this->is_addon() ) { return $this->_parent->addon_url( $this->_slug ); } return $this->_get_admin_page_url( 'pricing', $params ); }
php
function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) { $this->_logger->entrance(); $params = array( 'billing_cycle' => $billing_cycle ); if ( $is_trial ) { $params['trial'] = 'true'; } if ( $this->is_addon() ) { return $this->_parent->addon_url( $this->_slug ); } return $this->_get_admin_page_url( 'pricing', $params ); }
[ "function", "pricing_url", "(", "$", "billing_cycle", "=", "WP_FS__PERIOD_ANNUALLY", ",", "$", "is_trial", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "params", "=", "array", "(", "'billing_cycle'", "=>", "$"...
Plugin's pricing URL. @author Vova Feldman (@svovaf) @since 1.0.4 @param string $billing_cycle Billing cycle @param bool $is_trial @return string
[ "Plugin", "s", "pricing", "URL", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L11985-L12001
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.checkout_url
function checkout_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false, $extra = array() ) { $this->_logger->entrance(); $params = array( 'checkout' => 'true', 'billing_cycle' => $billing_cycle, ); if ( $is_trial ) { $params['trial'] = 'true'; } /** * Params in extra override other params. */ $params = array_merge( $params, $extra ); return $this->_get_admin_page_url( 'pricing', $params ); }
php
function checkout_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false, $extra = array() ) { $this->_logger->entrance(); $params = array( 'checkout' => 'true', 'billing_cycle' => $billing_cycle, ); if ( $is_trial ) { $params['trial'] = 'true'; } /** * Params in extra override other params. */ $params = array_merge( $params, $extra ); return $this->_get_admin_page_url( 'pricing', $params ); }
[ "function", "checkout_url", "(", "$", "billing_cycle", "=", "WP_FS__PERIOD_ANNUALLY", ",", "$", "is_trial", "=", "false", ",", "$", "extra", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "params", ...
Checkout page URL. @author Vova Feldman (@svovaf) @since 1.0.6 @param string $billing_cycle Billing cycle @param bool $is_trial @param array $extra (optional) Extra parameters, override other query params. @return string
[ "Checkout", "page", "URL", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12015-L12037
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.addon_checkout_url
function addon_checkout_url( $addon_id, $pricing_id, $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) { return $this->checkout_url( $billing_cycle, $is_trial, array( 'plugin_id' => $addon_id, 'pricing_id' => $pricing_id, ) ); }
php
function addon_checkout_url( $addon_id, $pricing_id, $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) { return $this->checkout_url( $billing_cycle, $is_trial, array( 'plugin_id' => $addon_id, 'pricing_id' => $pricing_id, ) ); }
[ "function", "addon_checkout_url", "(", "$", "addon_id", ",", "$", "pricing_id", ",", "$", "billing_cycle", "=", "WP_FS__PERIOD_ANNUALLY", ",", "$", "is_trial", "=", "false", ")", "{", "return", "$", "this", "->", "checkout_url", "(", "$", "billing_cycle", ",",...
Add-on checkout URL. @author Vova Feldman (@svovaf) @since 1.1.7 @param number $addon_id @param number $pricing_id @param string $billing_cycle @param bool $is_trial @return string
[ "Add", "-", "on", "checkout", "URL", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12052-L12062
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_ajax_action
function is_ajax_action( $actions ) { // Verify it's an ajax call. if ( ! self::is_ajax() ) { return false; } // Verify the call is relevant for the plugin. if ( $this->_module_id != fs_request_get( 'module_id' ) ) { return false; } // Verify it's one of the specified actions. if ( is_string( $actions ) ) { $actions = explode( ',', $actions ); } if ( is_array( $actions ) && 0 < count( $actions ) ) { $ajax_action = fs_request_get( 'action' ); foreach ( $actions as $action ) { if ( $ajax_action === $this->get_action_tag( $action ) ) { return true; } } } return false; }
php
function is_ajax_action( $actions ) { // Verify it's an ajax call. if ( ! self::is_ajax() ) { return false; } // Verify the call is relevant for the plugin. if ( $this->_module_id != fs_request_get( 'module_id' ) ) { return false; } // Verify it's one of the specified actions. if ( is_string( $actions ) ) { $actions = explode( ',', $actions ); } if ( is_array( $actions ) && 0 < count( $actions ) ) { $ajax_action = fs_request_get( 'action' ); foreach ( $actions as $action ) { if ( $ajax_action === $this->get_action_tag( $action ) ) { return true; } } } return false; }
[ "function", "is_ajax_action", "(", "$", "actions", ")", "{", "// Verify it's an ajax call.\r", "if", "(", "!", "self", "::", "is_ajax", "(", ")", ")", "{", "return", "false", ";", "}", "// Verify the call is relevant for the plugin.\r", "if", "(", "$", "this", "...
Check if it's an AJAX call targeted for the current module. @author Vova Feldman (@svovaf) @since 1.2.0 @param array|string $actions Collection of AJAX actions. @return bool
[ "Check", "if", "it", "s", "an", "AJAX", "call", "targeted", "for", "the", "current", "module", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12223-L12250
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_ajax_action_static
static function is_ajax_action_static( $actions, $module_id = null ) { // Verify it's an ajax call. if ( ! self::is_ajax() ) { return false; } if ( ! empty( $module_id ) ) { // Verify the call is relevant for the plugin. if ( $module_id != fs_request_get( 'module_id' ) ) { return false; } } // Verify it's one of the specified actions. if ( is_string( $actions ) ) { $actions = explode( ',', $actions ); } if ( is_array( $actions ) && 0 < count( $actions ) ) { $ajax_action = fs_request_get( 'action' ); foreach ( $actions as $action ) { if ( $ajax_action === self::get_ajax_action_static( $action, $module_id ) ) { return true; } } } return false; }
php
static function is_ajax_action_static( $actions, $module_id = null ) { // Verify it's an ajax call. if ( ! self::is_ajax() ) { return false; } if ( ! empty( $module_id ) ) { // Verify the call is relevant for the plugin. if ( $module_id != fs_request_get( 'module_id' ) ) { return false; } } // Verify it's one of the specified actions. if ( is_string( $actions ) ) { $actions = explode( ',', $actions ); } if ( is_array( $actions ) && 0 < count( $actions ) ) { $ajax_action = fs_request_get( 'action' ); foreach ( $actions as $action ) { if ( $ajax_action === self::get_ajax_action_static( $action, $module_id ) ) { return true; } } } return false; }
[ "static", "function", "is_ajax_action_static", "(", "$", "actions", ",", "$", "module_id", "=", "null", ")", "{", "// Verify it's an ajax call.\r", "if", "(", "!", "self", "::", "is_ajax", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", ...
Check if it's an AJAX call targeted for current request. @author Vova Feldman (@svovaf) @since 1.2.0 @param array|string $actions Collection of AJAX actions. @param number|null $module_id @return bool
[ "Check", "if", "it", "s", "an", "AJAX", "call", "targeted", "for", "current", "request", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12263-L12293
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_ssl_and_plan
function is_ssl_and_plan( $plan, $exact = false ) { return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) ); }
php
function is_ssl_and_plan( $plan, $exact = false ) { return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) ); }
[ "function", "is_ssl_and_plan", "(", "$", "plan", ",", "$", "exact", "=", "false", ")", "{", "return", "(", "$", "this", "->", "is_ssl", "(", ")", "&&", "$", "this", "->", "is_plan", "(", "$", "plan", ",", "$", "exact", ")", ")", ";", "}" ]
Check if running in HTTPS and if site's plan matching the specified plan. @param string $plan @param bool $exact @return bool
[ "Check", "if", "running", "in", "HTTPS", "and", "if", "site", "s", "plan", "matching", "the", "specified", "plan", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12337-L12339
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_delegated_connection
function is_delegated_connection( $blog_id = 0 ) { if ( ! $this->_is_network_active ) { return false; } if ( fs_is_network_admin() && 0 == $blog_id ) { return $this->is_network_delegated_connection(); } return ( $this->is_network_delegated_connection() || $this->is_site_delegated_connection( $blog_id ) ); }
php
function is_delegated_connection( $blog_id = 0 ) { if ( ! $this->_is_network_active ) { return false; } if ( fs_is_network_admin() && 0 == $blog_id ) { return $this->is_network_delegated_connection(); } return ( $this->is_network_delegated_connection() || $this->is_site_delegated_connection( $blog_id ) ); }
[ "function", "is_delegated_connection", "(", "$", "blog_id", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "return", "false", ";", "}", "if", "(", "fs_is_network_admin", "(", ")", "&&", "0", "==", "$", "blog_id", ...
Check if delegated the connection. When running within the the network admin, and haven't specified the blog ID, checks if network level delegated. If running within a site admin or specified a blog ID, check if delegated the connection for the current context site. If executed outside the the admin, check if delegated the connection for the current context site OR the whole network. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id If set, checks if network delegated or blog specific delegated. @return bool
[ "Check", "if", "delegated", "the", "connection", ".", "When", "running", "within", "the", "the", "network", "admin", "and", "haven", "t", "specified", "the", "blog", "ID", "checks", "if", "network", "level", "delegated", ".", "If", "running", "within", "a", ...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12550-L12563
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_active_for_site
function is_active_for_site( $blog_id ) { if ( ! is_multisite() ) { // Not a multisite and this code is executed, means that the plugin is active. return true; } if ( $this->is_theme() ) { // All themes are site level activated. return true; } if ( $this->_is_network_active ) { // Plugin was network activated so it's active. return true; } return in_array( $this->_plugin_basename, (array) get_blog_option( $blog_id, 'active_plugins', array() ) ); }
php
function is_active_for_site( $blog_id ) { if ( ! is_multisite() ) { // Not a multisite and this code is executed, means that the plugin is active. return true; } if ( $this->is_theme() ) { // All themes are site level activated. return true; } if ( $this->_is_network_active ) { // Plugin was network activated so it's active. return true; } return in_array( $this->_plugin_basename, (array) get_blog_option( $blog_id, 'active_plugins', array() ) ); }
[ "function", "is_active_for_site", "(", "$", "blog_id", ")", "{", "if", "(", "!", "is_multisite", "(", ")", ")", "{", "// Not a multisite and this code is executed, means that the plugin is active.\r", "return", "true", ";", "}", "if", "(", "$", "this", "->", "is_the...
Check if the current module is active for the site. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id @return bool
[ "Check", "if", "the", "current", "module", "is", "active", "for", "the", "site", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12575-L12592
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_site_active
private static function is_site_active( $blog_id ) { global $wpdb; $blog_info = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d", $blog_id ) ); if ( ! is_object( $blog_info ) ) { return false; } return ( true == $blog_info->public && false == $blog_info->archived && false == $blog_info->mature && false == $blog_info->spam && false == $blog_info->deleted ); }
php
private static function is_site_active( $blog_id ) { global $wpdb; $blog_info = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d", $blog_id ) ); if ( ! is_object( $blog_info ) ) { return false; } return ( true == $blog_info->public && false == $blog_info->archived && false == $blog_info->mature && false == $blog_info->spam && false == $blog_info->deleted ); }
[ "private", "static", "function", "is_site_active", "(", "$", "blog_id", ")", "{", "global", "$", "wpdb", ";", "$", "blog_info", "=", "$", "wpdb", "->", "get_row", "(", "$", "wpdb", "->", "prepare", "(", "\"SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d\"", ",",...
Checks if a given blog is active. @author Vova Feldman (@svovaf) @since 2.0.0 @param $blog_id @return bool
[ "Checks", "if", "a", "given", "blog", "is", "active", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12642-L12658
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_user_opted_in_module_ids_map
private static function get_user_opted_in_module_ids_map( $fs_user_id ) { self::$_static_logger->entrance(); if ( ! is_multisite() ) { $installs = array_merge( self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN ), self::get_all_sites( WP_FS__MODULE_TYPE_THEME ) ); } else { $sites = self::get_sites(); $installs = array(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $installs = array_merge( $installs, self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id ), self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id ) ); } } $module_ids_map = array(); foreach ( $installs as $install ) { if ( is_object( $install ) && FS_Site::is_valid_id( $install->id ) && FS_User::is_valid_id( $install->user_id ) && ( $install->user_id == $fs_user_id ) ) { $module_ids_map[ $install->plugin_id ] = true; } } return $module_ids_map; }
php
private static function get_user_opted_in_module_ids_map( $fs_user_id ) { self::$_static_logger->entrance(); if ( ! is_multisite() ) { $installs = array_merge( self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN ), self::get_all_sites( WP_FS__MODULE_TYPE_THEME ) ); } else { $sites = self::get_sites(); $installs = array(); foreach ( $sites as $site ) { $blog_id = self::get_site_blog_id( $site ); $installs = array_merge( $installs, self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id ), self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id ) ); } } $module_ids_map = array(); foreach ( $installs as $install ) { if ( is_object( $install ) && FS_Site::is_valid_id( $install->id ) && FS_User::is_valid_id( $install->user_id ) && ( $install->user_id == $fs_user_id ) ) { $module_ids_map[ $install->plugin_id ] = true; } } return $module_ids_map; }
[ "private", "static", "function", "get_user_opted_in_module_ids_map", "(", "$", "fs_user_id", ")", "{", "self", "::", "$", "_static_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "is_multisite", "(", ")", ")", "{", "$", "installs", "=", "array_merg...
Gets a map of module IDs that the given user has opted-in to. @author Leo Fajardo (@leorw) @since 2.1.0 @param number $fs_user_id @return array { @key number $plugin_id @value bool Always true. }
[ "Gets", "a", "map", "of", "module", "IDs", "that", "the", "given", "user", "has", "opted", "-", "in", "to", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12727-L12762
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.switch_to_blog
function switch_to_blog( $blog_id, FS_Site $install = null ) { if ( $blog_id == $this->_context_is_network_or_blog_id ) { return; } switch_to_blog( $blog_id ); $this->_context_is_network_or_blog_id = $blog_id; self::$_accounts->set_site_blog_context( $blog_id ); $this->_storage->set_site_blog_context( $blog_id ); $this->_storage->set_network_active( $this->_is_network_active, $this->is_delegated_connection( $blog_id ) ); $this->_site = is_object( $install ) ? $install : $this->get_install_by_blog_id( $blog_id ); $this->_user = false; $this->_licenses = false; $this->_license = null; if ( is_object( $this->_site ) ) { // Try to fetch user from install. $this->_user = self::_get_user_by_id( $this->_site->user_id ); if ( ! is_object( $this->_user ) && FS_User::is_valid_id( $this->_storage->prev_user_id ) ) { // Try to fetch previously saved user. $this->_user = self::_get_user_by_id( $this->_storage->prev_user_id ); if ( ! is_object( $this->_user ) ) { // Fallback to network's user. $this->_user = $this->get_network_user(); } } $all_plugin_licenses = self::get_all_licenses( $this->_module_id ); if ( ! empty( $all_plugin_licenses ) ) { if ( ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) { $this->_license = null; } else { $license_found = false; foreach ( $all_plugin_licenses as $license ) { if ( $license->id == $this->_site->license_id ) { // License found. $this->_license = $license; $license_found = true; break; } } if ( $license_found ) { $this->link_license_2_user( $this->_license->id, $this->_user->id ); } } $this->_licenses = $this->get_user_licenses( $this->_user->id ); } } unset( $this->_site_api ); unset( $this->_user_api ); }
php
function switch_to_blog( $blog_id, FS_Site $install = null ) { if ( $blog_id == $this->_context_is_network_or_blog_id ) { return; } switch_to_blog( $blog_id ); $this->_context_is_network_or_blog_id = $blog_id; self::$_accounts->set_site_blog_context( $blog_id ); $this->_storage->set_site_blog_context( $blog_id ); $this->_storage->set_network_active( $this->_is_network_active, $this->is_delegated_connection( $blog_id ) ); $this->_site = is_object( $install ) ? $install : $this->get_install_by_blog_id( $blog_id ); $this->_user = false; $this->_licenses = false; $this->_license = null; if ( is_object( $this->_site ) ) { // Try to fetch user from install. $this->_user = self::_get_user_by_id( $this->_site->user_id ); if ( ! is_object( $this->_user ) && FS_User::is_valid_id( $this->_storage->prev_user_id ) ) { // Try to fetch previously saved user. $this->_user = self::_get_user_by_id( $this->_storage->prev_user_id ); if ( ! is_object( $this->_user ) ) { // Fallback to network's user. $this->_user = $this->get_network_user(); } } $all_plugin_licenses = self::get_all_licenses( $this->_module_id ); if ( ! empty( $all_plugin_licenses ) ) { if ( ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) { $this->_license = null; } else { $license_found = false; foreach ( $all_plugin_licenses as $license ) { if ( $license->id == $this->_site->license_id ) { // License found. $this->_license = $license; $license_found = true; break; } } if ( $license_found ) { $this->link_license_2_user( $this->_license->id, $this->_user->id ); } } $this->_licenses = $this->get_user_licenses( $this->_user->id ); } } unset( $this->_site_api ); unset( $this->_user_api ); }
[ "function", "switch_to_blog", "(", "$", "blog_id", ",", "FS_Site", "$", "install", "=", "null", ")", "{", "if", "(", "$", "blog_id", "==", "$", "this", "->", "_context_is_network_or_blog_id", ")", "{", "return", ";", "}", "switch_to_blog", "(", "$", "blog_...
Switches the Freemius site level context to a specified blog. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $blog_id @param FS_Site $install
[ "Switches", "the", "Freemius", "site", "level", "context", "to", "a", "specified", "blog", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12799-L12862
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_install_by_blog_id
function get_install_by_blog_id( $blog_id = null ) { $installs = self::get_all_sites( $this->_module_type, $blog_id ); $install = isset( $installs[ $this->_slug ] ) ? $installs[ $this->_slug ] : null; if ( is_object( $install ) && is_numeric( $install->id ) && is_numeric( $install->user_id ) && FS_Plugin_Plan::is_valid_id( $install->plan_id ) ) { // Load site. $install = clone $install; } return $install; }
php
function get_install_by_blog_id( $blog_id = null ) { $installs = self::get_all_sites( $this->_module_type, $blog_id ); $install = isset( $installs[ $this->_slug ] ) ? $installs[ $this->_slug ] : null; if ( is_object( $install ) && is_numeric( $install->id ) && is_numeric( $install->user_id ) && FS_Plugin_Plan::is_valid_id( $install->plan_id ) ) { // Load site. $install = clone $install; } return $install; }
[ "function", "get_install_by_blog_id", "(", "$", "blog_id", "=", "null", ")", "{", "$", "installs", "=", "self", "::", "get_all_sites", "(", "$", "this", "->", "_module_type", ",", "$", "blog_id", ")", ";", "$", "install", "=", "isset", "(", "$", "install...
Load the module's install based on the blog ID. @author Vova Feldman (@svovaf) @since 2.0.0 @param int|null $blog_id @return FS_Site
[ "Load", "the", "module", "s", "install", "based", "on", "the", "blog", "ID", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L12953-L12967
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_network_user
function get_network_user() { if ( ! $this->_is_network_active ) { return null; } return FS_User::is_valid_id( $this->_storage->network_user_id ) ? self::_get_user_by_id( $this->_storage->network_user_id ) : null; }
php
function get_network_user() { if ( ! $this->_is_network_active ) { return null; } return FS_User::is_valid_id( $this->_storage->network_user_id ) ? self::_get_user_by_id( $this->_storage->network_user_id ) : null; }
[ "function", "get_network_user", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "return", "null", ";", "}", "return", "FS_User", "::", "is_valid_id", "(", "$", "this", "->", "_storage", "->", "network_user_id", ")", "?", ...
Returns the main user associated with the network. @author Vova Feldman (@svovaf) @since 2.0.0 @return FS_User
[ "Returns", "the", "main", "user", "associated", "with", "the", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13015-L13023
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_network_install
function get_network_install() { if ( ! $this->_is_network_active ) { return null; } return FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ? $this->get_install_by_blog_id( $this->_storage->network_install_blog_id ) : null; }
php
function get_network_install() { if ( ! $this->_is_network_active ) { return null; } return FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ? $this->get_install_by_blog_id( $this->_storage->network_install_blog_id ) : null; }
[ "function", "get_network_install", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "return", "null", ";", "}", "return", "FS_Site", "::", "is_valid_id", "(", "$", "this", "->", "_storage", "->", "network_install_blog_id", ")...
Returns the main install associated with the network. @author Vova Feldman (@svovaf) @since 2.0.0 @return FS_Site
[ "Returns", "the", "main", "install", "associated", "with", "the", "network", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13047-L13055
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_network_install_blog_id
function get_network_install_blog_id() { if ( ! $this->_is_network_active ) { return null; } return FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ? $this->_storage->network_install_blog_id : null; }
php
function get_network_install_blog_id() { if ( ! $this->_is_network_active ) { return null; } return FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ? $this->_storage->network_install_blog_id : null; }
[ "function", "get_network_install_blog_id", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "return", "null", ";", "}", "return", "FS_Site", "::", "is_valid_id", "(", "$", "this", "->", "_storage", "->", "network_install_blog_i...
Returns the blog ID that is associated with the main install. @author Leo Fajardo (@leorw) @since 2.0.0 @return int|null
[ "Returns", "the", "blog", "ID", "that", "is", "associated", "with", "the", "main", "install", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13065-L13073
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.is_network_level_site_specific_action
private function is_network_level_site_specific_action() { if ( ! $this->_is_network_active ) { return false; } if ( ! fs_is_network_admin() ) { return false; } $blog_id = fs_request_get( 'blog_id', '' ); return is_numeric( $blog_id ) ? $blog_id : false; }
php
private function is_network_level_site_specific_action() { if ( ! $this->_is_network_active ) { return false; } if ( ! fs_is_network_admin() ) { return false; } $blog_id = fs_request_get( 'blog_id', '' ); return is_numeric( $blog_id ) ? $blog_id : false; }
[ "private", "function", "is_network_level_site_specific_action", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "return", "false", ";", "}", "if", "(", "!", "fs_is_network_admin", "(", ")", ")", "{", "return", "false", ";", ...
Check if executing a site level action from the network level admin. @author Vova Feldman (@svovaf) @since 2.0.0 @return false|int If yes, return the requested blog ID.
[ "Check", "if", "executing", "a", "site", "level", "action", "from", "the", "network", "level", "admin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13097-L13109
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.update_multisite_data_after_site_deactivation
private function update_multisite_data_after_site_deactivation( $context_blog_id = 0 ) { $this->_logger->entrance(); if ( $this->_is_network_active ) { if ( $context_blog_id == $this->_storage->network_install_blog_id ) { $installs_map = $this->get_blog_install_map(); foreach ( $installs_map as $blog_id => $install ) { /** * @var FS_Site $install */ if ( $context_blog_id == $blog_id ) { continue; } if ( $install->user_id != $this->_storage->network_user_id ) { continue; } // Switch reference to a blog that is opted-in and belong to the same super-admin. $this->_storage->network_install_blog_id = $blog_id; break; } } } if ( $this->is_sync_cron_scheduled() && $context_blog_id == $this->get_sync_cron_blog_id() ) { $this->schedule_sync_cron( WP_FS__SCRIPT_START_TIME, true, $context_blog_id ); } if ( $this->is_install_sync_scheduled() && $context_blog_id == $this->get_install_sync_cron_blog_id() ) { $this->schedule_install_sync( $context_blog_id ); } }
php
private function update_multisite_data_after_site_deactivation( $context_blog_id = 0 ) { $this->_logger->entrance(); if ( $this->_is_network_active ) { if ( $context_blog_id == $this->_storage->network_install_blog_id ) { $installs_map = $this->get_blog_install_map(); foreach ( $installs_map as $blog_id => $install ) { /** * @var FS_Site $install */ if ( $context_blog_id == $blog_id ) { continue; } if ( $install->user_id != $this->_storage->network_user_id ) { continue; } // Switch reference to a blog that is opted-in and belong to the same super-admin. $this->_storage->network_install_blog_id = $blog_id; break; } } } if ( $this->is_sync_cron_scheduled() && $context_blog_id == $this->get_sync_cron_blog_id() ) { $this->schedule_sync_cron( WP_FS__SCRIPT_START_TIME, true, $context_blog_id ); } if ( $this->is_install_sync_scheduled() && $context_blog_id == $this->get_install_sync_cron_blog_id() ) { $this->schedule_install_sync( $context_blog_id ); } }
[ "private", "function", "update_multisite_data_after_site_deactivation", "(", "$", "context_blog_id", "=", "0", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "_is_network_active", ")", "{", "if", "(", "...
Needs to be executed after site deactivation, archive, deletion, or flag as spam. The logic updates the network level user and blog, and reschedule the crons if the cron executing site matching the site that is no longer publicly active. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $context_blog_id
[ "Needs", "to", "be", "executed", "after", "site", "deactivation", "archive", "deletion", "or", "flag", "as", "spam", ".", "The", "logic", "updates", "the", "network", "level", "user", "and", "blog", "and", "reschedule", "the", "crons", "if", "the", "cron", ...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13132-L13169
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._after_site_deactivated_callback
public function _after_site_deactivated_callback( $context_blog_id = 0 ) { $this->_logger->entrance(); $install = $this->get_install_by_blog_id( $context_blog_id ); if ( ! is_object( $install ) ) { // Site not connected. return; } $this->update_multisite_data_after_site_deactivation( $context_blog_id ); $current_blog_id = get_current_blog_id(); $this->switch_to_blog( $context_blog_id ); // Send deactivation event. $this->sync_install( array( 'is_active' => false, ) ); $this->switch_to_blog( $current_blog_id ); }
php
public function _after_site_deactivated_callback( $context_blog_id = 0 ) { $this->_logger->entrance(); $install = $this->get_install_by_blog_id( $context_blog_id ); if ( ! is_object( $install ) ) { // Site not connected. return; } $this->update_multisite_data_after_site_deactivation( $context_blog_id ); $current_blog_id = get_current_blog_id(); $this->switch_to_blog( $context_blog_id ); // Send deactivation event. $this->sync_install( array( 'is_active' => false, ) ); $this->switch_to_blog( $current_blog_id ); }
[ "public", "function", "_after_site_deactivated_callback", "(", "$", "context_blog_id", "=", "0", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "install", "=", "$", "this", "->", "get_install_by_blog_id", "(", "$", "context_blog_...
Executed after site deactivation, archive, or flag as spam. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $context_blog_id
[ "Executed", "after", "site", "deactivation", "archive", "or", "flag", "as", "spam", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13179-L13201
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._after_site_deleted_callback
public function _after_site_deleted_callback( $context_blog_id = 0, $drop = false ) { $this->_logger->entrance(); $install = $this->get_install_by_blog_id( $context_blog_id ); if ( ! is_object( $install ) ) { // Site not connected. return; } $this->update_multisite_data_after_site_deactivation( $context_blog_id ); $current_blog_id = get_current_blog_id(); $this->switch_to_blog( $context_blog_id ); if ( $drop ) { // Delete install if dropping site DB. $this->delete_account_event(); } else { // Send deactivation event. $this->sync_install( array( 'is_active' => false, ) ); } $this->switch_to_blog( $current_blog_id ); }
php
public function _after_site_deleted_callback( $context_blog_id = 0, $drop = false ) { $this->_logger->entrance(); $install = $this->get_install_by_blog_id( $context_blog_id ); if ( ! is_object( $install ) ) { // Site not connected. return; } $this->update_multisite_data_after_site_deactivation( $context_blog_id ); $current_blog_id = get_current_blog_id(); $this->switch_to_blog( $context_blog_id ); if ( $drop ) { // Delete install if dropping site DB. $this->delete_account_event(); } else { // Send deactivation event. $this->sync_install( array( 'is_active' => false, ) ); } $this->switch_to_blog( $current_blog_id ); }
[ "public", "function", "_after_site_deleted_callback", "(", "$", "context_blog_id", "=", "0", ",", "$", "drop", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "install", "=", "$", "this", "->", "get_install_by_bl...
Executed after site deletion. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $context_blog_id @param bool $drop True if site's database tables should be dropped. Default is false.
[ "Executed", "after", "site", "deletion", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13212-L13239
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._after_site_reactivated_callback
public function _after_site_reactivated_callback( $context_blog_id = 0 ) { $this->_logger->entrance(); $install = $this->get_install_by_blog_id( $context_blog_id ); if ( ! is_object( $install ) ) { // Site not connected. return; } if ( ! self::is_site_active( $context_blog_id ) ) { // Site not yet active (can be in spam mode, archived, deleted...). return; } $current_blog_id = get_current_blog_id(); $this->switch_to_blog( $context_blog_id ); // Send re-activation event. $this->sync_install( array( 'is_active' => true, ) ); $this->switch_to_blog( $current_blog_id ); }
php
public function _after_site_reactivated_callback( $context_blog_id = 0 ) { $this->_logger->entrance(); $install = $this->get_install_by_blog_id( $context_blog_id ); if ( ! is_object( $install ) ) { // Site not connected. return; } if ( ! self::is_site_active( $context_blog_id ) ) { // Site not yet active (can be in spam mode, archived, deleted...). return; } $current_blog_id = get_current_blog_id(); $this->switch_to_blog( $context_blog_id ); // Send re-activation event. $this->sync_install( array( 'is_active' => true, ) ); $this->switch_to_blog( $current_blog_id ); }
[ "public", "function", "_after_site_reactivated_callback", "(", "$", "context_blog_id", "=", "0", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "install", "=", "$", "this", "->", "get_install_by_blog_id", "(", "$", "context_blog_...
Executed after site re-activation. @author Vova Feldman (@svovaf) @since 2.0.0 @param int $context_blog_id
[ "Executed", "after", "site", "re", "-", "activation", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13249-L13274
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._get_sync_license_url
function _get_sync_license_url( $plugin_id = false, $add_action_nonce = true, $params = array() ) { if ( is_numeric( $plugin_id ) ) { $params['plugin_id'] = $plugin_id; } return $this->get_account_url( $this->get_unique_affix() . '_sync_license', $params, $add_action_nonce ); }
php
function _get_sync_license_url( $plugin_id = false, $add_action_nonce = true, $params = array() ) { if ( is_numeric( $plugin_id ) ) { $params['plugin_id'] = $plugin_id; } return $this->get_account_url( $this->get_unique_affix() . '_sync_license', $params, $add_action_nonce ); }
[ "function", "_get_sync_license_url", "(", "$", "plugin_id", "=", "false", ",", "$", "add_action_nonce", "=", "true", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "plugin_id", ")", ")", "{", "$", "params", "["...
Plugin's account page + sync license URL. @author Vova Feldman (@svovaf) @since 1.1.9.1 @param bool|number $plugin_id @param bool $add_action_nonce @param array $params @return string
[ "Plugin", "s", "account", "page", "+", "sync", "license", "URL", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13347-L13357
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._activate_account
function _activate_account() { if ( $this->is_registered() ) { // Already activated. return; } self::_clean_admin_content_section(); if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) { // check_admin_referer( 'activate_' . $this->_plugin->public_key ); // Verify matching plugin details. if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) { return; } $user = new FS_User(); $user->id = fs_request_get( 'user_id' ); $user->public_key = fs_request_get( 'user_public_key' ); $user->secret_key = fs_request_get( 'user_secret_key' ); $user->email = fs_request_get( 'user_email' ); $user->first = fs_request_get( 'user_first' ); $user->last = fs_request_get( 'user_last' ); $user->is_verified = fs_request_get_bool( 'user_is_verified' ); $site = new FS_Site(); $site->id = fs_request_get( 'install_id' ); $site->public_key = fs_request_get( 'install_public_key' ); $site->secret_key = fs_request_get( 'install_secret_key' ); $site->plan_id = fs_request_get( 'plan_id' ); $plans = array(); $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) ); foreach ( $plans_data as $p ) { $plan = new FS_Plugin_Plan( $p ); if ( $site->plan_id == $plan->id ) { $plan->title = fs_request_get( 'plan_title' ); $plan->name = fs_request_get( 'plan_name' ); } $plans[] = $plan; } $this->_set_account( $user, $site, $plans ); // Reload the page with the keys. fs_redirect( $this->_get_admin_page_url() ); } }
php
function _activate_account() { if ( $this->is_registered() ) { // Already activated. return; } self::_clean_admin_content_section(); if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) { // check_admin_referer( 'activate_' . $this->_plugin->public_key ); // Verify matching plugin details. if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) { return; } $user = new FS_User(); $user->id = fs_request_get( 'user_id' ); $user->public_key = fs_request_get( 'user_public_key' ); $user->secret_key = fs_request_get( 'user_secret_key' ); $user->email = fs_request_get( 'user_email' ); $user->first = fs_request_get( 'user_first' ); $user->last = fs_request_get( 'user_last' ); $user->is_verified = fs_request_get_bool( 'user_is_verified' ); $site = new FS_Site(); $site->id = fs_request_get( 'install_id' ); $site->public_key = fs_request_get( 'install_public_key' ); $site->secret_key = fs_request_get( 'install_secret_key' ); $site->plan_id = fs_request_get( 'plan_id' ); $plans = array(); $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) ); foreach ( $plans_data as $p ) { $plan = new FS_Plugin_Plan( $p ); if ( $site->plan_id == $plan->id ) { $plan->title = fs_request_get( 'plan_title' ); $plan->name = fs_request_get( 'plan_name' ); } $plans[] = $plan; } $this->_set_account( $user, $site, $plans ); // Reload the page with the keys. fs_redirect( $this->_get_admin_page_url() ); } }
[ "function", "_activate_account", "(", ")", "{", "if", "(", "$", "this", "->", "is_registered", "(", ")", ")", "{", "// Already activated.\r", "return", ";", "}", "self", "::", "_clean_admin_content_section", "(", ")", ";", "if", "(", "fs_request_is_action", "(...
Tries to activate account based on POST params. @author Vova Feldman (@svovaf) @since 1.0.2 @deprecated Not in use, outdated.
[ "Tries", "to", "activate", "account", "based", "on", "POST", "params", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13569-L13617
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.fetch_user_by_install
private function fetch_user_by_install() { $api = $this->get_api_site_scope(); $uid = $this->get_anonymous_id(); $request_path = "/users/{$this->_site->user_id}.json?uid={$uid}"; $result = $api->get( $request_path, false, WP_FS__TIME_10_MIN_IN_SEC ); if ( $this->is_api_result_entity( $result ) ) { $user = new FS_User( $result ); $this->_user = $user; $this->_store_user(); return $user; } $error_code = FS_Api::get_error_code( $result ); if ( in_array( $error_code, array( 'invalid_unique_id', 'user_cannot_be_recovered' ) ) ) { /** * Those API errors will continue coming and are not recoverable with the * current site's data. Therefore, extend the API call's cached result to 7 days. */ $api->update_cache_expiration( $request_path, WP_FS__TIME_WEEK_IN_SEC ); } return $result; }
php
private function fetch_user_by_install() { $api = $this->get_api_site_scope(); $uid = $this->get_anonymous_id(); $request_path = "/users/{$this->_site->user_id}.json?uid={$uid}"; $result = $api->get( $request_path, false, WP_FS__TIME_10_MIN_IN_SEC ); if ( $this->is_api_result_entity( $result ) ) { $user = new FS_User( $result ); $this->_user = $user; $this->_store_user(); return $user; } $error_code = FS_Api::get_error_code( $result ); if ( in_array( $error_code, array( 'invalid_unique_id', 'user_cannot_be_recovered' ) ) ) { /** * Those API errors will continue coming and are not recoverable with the * current site's data. Therefore, extend the API call's cached result to 7 days. */ $api->update_cache_expiration( $request_path, WP_FS__TIME_WEEK_IN_SEC ); } return $result; }
[ "private", "function", "fetch_user_by_install", "(", ")", "{", "$", "api", "=", "$", "this", "->", "get_api_site_scope", "(", ")", ";", "$", "uid", "=", "$", "this", "->", "get_anonymous_id", "(", ")", ";", "$", "request_path", "=", "\"/users/{$this->_site->...
Special user recovery mechanism. @author Vova Feldman (@svovaf) @since 2.0.0 @return \FS_User|mixed
[ "Special", "user", "recovery", "mechanism", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13777-L13804
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_versions
private function get_versions() { $versions = array(); $versions['platform_version'] = get_bloginfo( 'version' ); $versions['sdk_version'] = $this->version; $versions['programming_language_version'] = phpversion(); foreach ( $versions as $k => $version ) { if ( is_string( $versions[ $k ] ) && ! empty( $versions[ $k ] ) ) { $versions[ $k ] = substr( $versions[ $k ], 0, 16 ); } } return $versions; }
php
private function get_versions() { $versions = array(); $versions['platform_version'] = get_bloginfo( 'version' ); $versions['sdk_version'] = $this->version; $versions['programming_language_version'] = phpversion(); foreach ( $versions as $k => $version ) { if ( is_string( $versions[ $k ] ) && ! empty( $versions[ $k ] ) ) { $versions[ $k ] = substr( $versions[ $k ], 0, 16 ); } } return $versions; }
[ "private", "function", "get_versions", "(", ")", "{", "$", "versions", "=", "array", "(", ")", ";", "$", "versions", "[", "'platform_version'", "]", "=", "get_bloginfo", "(", "'version'", ")", ";", "$", "versions", "[", "'sdk_version'", "]", "=", "$", "t...
Get a sanitized array with the WordPress version, SDK version, and PHP version. Each version is trimmed after the 16th char. @author Vova Feldman (@svovaf) @since 2.2.1 @return array
[ "Get", "a", "sanitized", "array", "with", "the", "WordPress", "version", "SDK", "version", "and", "PHP", "version", ".", "Each", "version", "is", "trimmed", "after", "the", "16th", "char", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L13838-L13851
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._install_with_new_user
function _install_with_new_user() { $this->_logger->entrance(); if ( $this->is_registered() ) { return; } if ( ( $this->is_plugin() && fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) || // @todo This logic should be improved because it's executed on every load of a theme. $this->is_theme() ) { // check_admin_referer( $this->_slug . '_activate_new' ); if ( fs_request_has( 'user_secret_key' ) ) { if ( fs_is_network_admin() && isset( $this->_storage->pending_sites_info ) ) { $pending_sites_info = $this->_storage->pending_sites_info; $this->install_many_pending_with_user( fs_request_get( 'user_id' ), fs_request_get( 'user_public_key' ), fs_request_get( 'user_secret_key' ), fs_request_get_bool( 'is_marketing_allowed', null ), $pending_sites_info['blog_ids'], $pending_sites_info['license_key'], $pending_sites_info['trial_plan_id'] ); } else { $this->install_with_new_user( fs_request_get( 'user_id' ), fs_request_get( 'user_public_key' ), fs_request_get( 'user_secret_key' ), fs_request_get_bool( 'is_marketing_allowed', null ), fs_request_get( 'install_id' ), fs_request_get( 'install_public_key' ), fs_request_get( 'install_secret_key' ), true, fs_request_get_bool( 'auto_install' ) ); } } else if ( fs_request_has( 'pending_activation' ) ) { $this->set_pending_confirmation( fs_request_get( 'user_email' ), true ); } } }
php
function _install_with_new_user() { $this->_logger->entrance(); if ( $this->is_registered() ) { return; } if ( ( $this->is_plugin() && fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) || // @todo This logic should be improved because it's executed on every load of a theme. $this->is_theme() ) { // check_admin_referer( $this->_slug . '_activate_new' ); if ( fs_request_has( 'user_secret_key' ) ) { if ( fs_is_network_admin() && isset( $this->_storage->pending_sites_info ) ) { $pending_sites_info = $this->_storage->pending_sites_info; $this->install_many_pending_with_user( fs_request_get( 'user_id' ), fs_request_get( 'user_public_key' ), fs_request_get( 'user_secret_key' ), fs_request_get_bool( 'is_marketing_allowed', null ), $pending_sites_info['blog_ids'], $pending_sites_info['license_key'], $pending_sites_info['trial_plan_id'] ); } else { $this->install_with_new_user( fs_request_get( 'user_id' ), fs_request_get( 'user_public_key' ), fs_request_get( 'user_secret_key' ), fs_request_get_bool( 'is_marketing_allowed', null ), fs_request_get( 'install_id' ), fs_request_get( 'install_public_key' ), fs_request_get( 'install_secret_key' ), true, fs_request_get_bool( 'auto_install' ) ); } } else if ( fs_request_has( 'pending_activation' ) ) { $this->set_pending_confirmation( fs_request_get( 'user_email' ), true ); } } }
[ "function", "_install_with_new_user", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "is_registered", "(", ")", ")", "{", "return", ";", "}", "if", "(", "(", "$", "this", "->", "is_plugin",...
Install plugin with new user information after approval. @author Vova Feldman (@svovaf) @since 1.0.7
[ "Install", "plugin", "with", "new", "user", "information", "after", "approval", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14449-L14492
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.install_with_new_user
private function install_with_new_user( $user_id, $user_public_key, $user_secret_key, $is_marketing_allowed, $install_id, $install_public_key, $install_secret_key, $redirect = true, $auto_install = false ) { /** * This method is also executed after opting in with a license key since the * license can be potentially associated with a different owner. * * @since 2.0.0 */ $user = self::_get_user_by_id( $user_id ); if ( ! is_object( $user ) ) { $user = new FS_User(); $user->id = $user_id; $user->public_key = $user_public_key; $user->secret_key = $user_secret_key; $this->_user = $user; $user_result = $this->get_api_user_scope()->get(); $user = new FS_User( $user_result ); } $this->_user = $user; $site = new FS_Site(); $site->id = $install_id; $site->public_key = $install_public_key; $site->secret_key = $install_secret_key; $this->_site = $site; $site_result = $this->get_api_site_scope()->get(); $site = new FS_Site( $site_result ); $this->_site = $site; if ( ! is_null( $is_marketing_allowed ) ) { $this->disable_opt_in_notice_and_lock_user(); } return $this->setup_account( $this->_user, $this->_site, $redirect, $auto_install ); }
php
private function install_with_new_user( $user_id, $user_public_key, $user_secret_key, $is_marketing_allowed, $install_id, $install_public_key, $install_secret_key, $redirect = true, $auto_install = false ) { /** * This method is also executed after opting in with a license key since the * license can be potentially associated with a different owner. * * @since 2.0.0 */ $user = self::_get_user_by_id( $user_id ); if ( ! is_object( $user ) ) { $user = new FS_User(); $user->id = $user_id; $user->public_key = $user_public_key; $user->secret_key = $user_secret_key; $this->_user = $user; $user_result = $this->get_api_user_scope()->get(); $user = new FS_User( $user_result ); } $this->_user = $user; $site = new FS_Site(); $site->id = $install_id; $site->public_key = $install_public_key; $site->secret_key = $install_secret_key; $this->_site = $site; $site_result = $this->get_api_site_scope()->get(); $site = new FS_Site( $site_result ); $this->_site = $site; if ( ! is_null( $is_marketing_allowed ) ) { $this->disable_opt_in_notice_and_lock_user(); } return $this->setup_account( $this->_user, $this->_site, $redirect, $auto_install ); }
[ "private", "function", "install_with_new_user", "(", "$", "user_id", ",", "$", "user_public_key", ",", "$", "user_secret_key", ",", "$", "is_marketing_allowed", ",", "$", "install_id", ",", "$", "install_public_key", ",", "$", "install_secret_key", ",", "$", "redi...
Install plugin with new user. @author Vova Feldman (@svovaf) @since 1.1.7.4 @param number $user_id @param string $user_public_key @param string $user_secret_key @param bool|null $is_marketing_allowed @param number $install_id @param string $install_public_key @param string $install_secret_key @param bool $redirect @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will redirect (or return a URL) to the account page with a special parameter to trigger the auto installation processes. @return string If redirect is `false`, returns the next page the user should be redirected to.
[ "Install", "plugin", "with", "new", "user", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14546-L14598
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.install_many_pending_with_user
private function install_many_pending_with_user( $user_id, $user_public_key, $user_secret_key, $is_marketing_allowed, $site_ids, $license_key = false, $trial_plan_id = false, $redirect = true ) { $user = $this->setup_user( $user_id, $user_public_key, $user_secret_key ); if ( ! is_null( $is_marketing_allowed ) ) { $this->disable_opt_in_notice_and_lock_user(); } $sites = array(); foreach ( $site_ids as $site_id ) { $sites[] = $this->get_site_info( array( 'blog_id' => $site_id ) ); } $this->install_with_user( $user, $license_key, $trial_plan_id, $redirect, true, $sites ); }
php
private function install_many_pending_with_user( $user_id, $user_public_key, $user_secret_key, $is_marketing_allowed, $site_ids, $license_key = false, $trial_plan_id = false, $redirect = true ) { $user = $this->setup_user( $user_id, $user_public_key, $user_secret_key ); if ( ! is_null( $is_marketing_allowed ) ) { $this->disable_opt_in_notice_and_lock_user(); } $sites = array(); foreach ( $site_ids as $site_id ) { $sites[] = $this->get_site_info( array( 'blog_id' => $site_id ) ); } $this->install_with_user( $user, $license_key, $trial_plan_id, $redirect, true, $sites ); }
[ "private", "function", "install_many_pending_with_user", "(", "$", "user_id", ",", "$", "user_public_key", ",", "$", "user_secret_key", ",", "$", "is_marketing_allowed", ",", "$", "site_ids", ",", "$", "license_key", "=", "false", ",", "$", "trial_plan_id", "=", ...
Install plugin with user. @author Leo Fajardo (@leorw) @since 2.0.0 @param number $user_id @param string $user_public_key @param string $user_secret_key @param bool|null $is_marketing_allowed @param array $site_ids @param bool $license_key @param bool $trial_plan_id @param bool $redirect @return string If redirect is `false`, returns the next page the user should be redirected to.
[ "Install", "plugin", "with", "user", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14617-L14639
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.install_many_with_new_user
private function install_many_with_new_user( $user_id, $user_public_key, $user_secret_key, $is_marketing_allowed, array $installs, $redirect = true, $auto_install = false ) { $this->setup_user( $user_id, $user_public_key, $user_secret_key ); if ( ! is_null( $is_marketing_allowed ) ) { $this->disable_opt_in_notice_and_lock_user(); } $install_ids = array(); foreach ( $installs as $install ) { $install_ids[] = $install->id; } $left = count( $install_ids ); $offset = 0; $installs = array(); while ( $left > 0 ) { $result = $this->get_api_user_scope()->get( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', array_slice( $install_ids, $offset, 25 ) ) ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { // @todo Handle API error. } $installs = array_merge( $installs, $result->installs ); $left -= 25; } foreach ( $installs as &$install ) { $install = new FS_Site( $install ); } return $this->setup_network_account( $this->_user, $installs, $redirect, $auto_install ); }
php
private function install_many_with_new_user( $user_id, $user_public_key, $user_secret_key, $is_marketing_allowed, array $installs, $redirect = true, $auto_install = false ) { $this->setup_user( $user_id, $user_public_key, $user_secret_key ); if ( ! is_null( $is_marketing_allowed ) ) { $this->disable_opt_in_notice_and_lock_user(); } $install_ids = array(); foreach ( $installs as $install ) { $install_ids[] = $install->id; } $left = count( $install_ids ); $offset = 0; $installs = array(); while ( $left > 0 ) { $result = $this->get_api_user_scope()->get( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', array_slice( $install_ids, $offset, 25 ) ) ); if ( ! $this->is_api_result_object( $result, 'installs' ) ) { // @todo Handle API error. } $installs = array_merge( $installs, $result->installs ); $left -= 25; } foreach ( $installs as &$install ) { $install = new FS_Site( $install ); } return $this->setup_network_account( $this->_user, $installs, $redirect, $auto_install ); }
[ "private", "function", "install_many_with_new_user", "(", "$", "user_id", ",", "$", "user_public_key", ",", "$", "user_secret_key", ",", "$", "is_marketing_allowed", ",", "array", "$", "installs", ",", "$", "redirect", "=", "true", ",", "$", "auto_install", "=",...
Multi-site install with a new user. @author Vova Feldman (@svovaf) @since 2.0.0 @param number $user_id @param string $user_public_key @param string $user_secret_key @param bool|null $is_marketing_allowed @param object[] $installs @param bool $redirect @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will redirect (or return a URL) to the account page with a special parameter to trigger the auto installation processes. @return string If redirect is `false`, returns the next page the user should be redirected to.
[ "Multi", "-", "site", "install", "with", "a", "new", "user", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14659-L14706
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._install_with_current_user
function _install_with_current_user() { $this->_logger->entrance(); if ( $this->is_registered() ) { return; } if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) && fs_request_is_post() ) { // check_admin_referer( 'activate_existing_' . $this->_plugin->public_key ); /** * @author Vova Feldman (@svovaf) * @since 1.1.9 Add license key if given. */ $license_key = fs_request_get( 'license_secret_key' ); $this->install_with_current_user( $license_key ); } }
php
function _install_with_current_user() { $this->_logger->entrance(); if ( $this->is_registered() ) { return; } if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) && fs_request_is_post() ) { // check_admin_referer( 'activate_existing_' . $this->_plugin->public_key ); /** * @author Vova Feldman (@svovaf) * @since 1.1.9 Add license key if given. */ $license_key = fs_request_get( 'license_secret_key' ); $this->install_with_current_user( $license_key ); } }
[ "function", "_install_with_current_user", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "is_registered", "(", ")", ")", "{", "return", ";", "}", "if", "(", "fs_request_is_action", "(", "$", ...
Install plugin with current logged WP user info. @author Vova Feldman (@svovaf) @since 1.0.7
[ "Install", "plugin", "with", "current", "logged", "WP", "user", "info", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14767-L14785
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.create_installs_with_user
private function create_installs_with_user( FS_User $user, $license_key = false, $trial_plan_id = false, $sites = array(), $redirect = false, $silent = false ) { $extra_install_params = array( 'uid' => $this->get_anonymous_id(), 'is_disconnected' => false, ); if ( ! empty( $license_key ) ) { $extra_install_params['license_key'] = $this->apply_filters( 'license_key', $license_key ); } else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) { $extra_install_params['trial_plan_id'] = $trial_plan_id; } if ( ! empty( $sites ) ) { $extra_install_params['sites'] = $sites; } $args = $this->get_install_data_for_api( $extra_install_params, false, false ); // Install the plugin. $result = $this->get_api_user_scope_by_user( $user )->call( "/plugins/{$this->get_id()}/installs.json", 'post', $args ); if ( ! $this->is_api_result_entity( $result ) && ! $this->is_api_result_object( $result, 'installs' ) ) { if ( ! empty( $args['license_key'] ) ) { // Pass full the fully entered license key to the failure handler. $args['license_key'] = $license_key; } $result = $this->apply_filters( 'after_install_failure', $result, $args ); if ( ! $silent ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' . $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $result->error->message . '</b>', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...', 'error' ); } if ( $redirect ) { /** * We set the user before getting the user scope API handler, so the user became temporarily * registered (`is_registered() = true`). Since the API returned an error and we will redirect, * we have to set the user to `null`, otherwise, the user will be redirected to the wrong * activation page based on the return value of `is_registered()`. In addition, in case the * context plugin doesn't have a settings menu and the default page is the `Plugins` page, * misleading plugin activation errors will be shown on the `Plugins` page. * * @author Leo Fajardo (@leorw) */ $this->_user = null; fs_redirect( $this->get_activation_url( array( 'error' => $result->error->message ) ) ); } } return $result; }
php
private function create_installs_with_user( FS_User $user, $license_key = false, $trial_plan_id = false, $sites = array(), $redirect = false, $silent = false ) { $extra_install_params = array( 'uid' => $this->get_anonymous_id(), 'is_disconnected' => false, ); if ( ! empty( $license_key ) ) { $extra_install_params['license_key'] = $this->apply_filters( 'license_key', $license_key ); } else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) { $extra_install_params['trial_plan_id'] = $trial_plan_id; } if ( ! empty( $sites ) ) { $extra_install_params['sites'] = $sites; } $args = $this->get_install_data_for_api( $extra_install_params, false, false ); // Install the plugin. $result = $this->get_api_user_scope_by_user( $user )->call( "/plugins/{$this->get_id()}/installs.json", 'post', $args ); if ( ! $this->is_api_result_entity( $result ) && ! $this->is_api_result_object( $result, 'installs' ) ) { if ( ! empty( $args['license_key'] ) ) { // Pass full the fully entered license key to the failure handler. $args['license_key'] = $license_key; } $result = $this->apply_filters( 'after_install_failure', $result, $args ); if ( ! $silent ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' . $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $result->error->message . '</b>', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...', 'error' ); } if ( $redirect ) { /** * We set the user before getting the user scope API handler, so the user became temporarily * registered (`is_registered() = true`). Since the API returned an error and we will redirect, * we have to set the user to `null`, otherwise, the user will be redirected to the wrong * activation page based on the return value of `is_registered()`. In addition, in case the * context plugin doesn't have a settings menu and the default page is the `Plugins` page, * misleading plugin activation errors will be shown on the `Plugins` page. * * @author Leo Fajardo (@leorw) */ $this->_user = null; fs_redirect( $this->get_activation_url( array( 'error' => $result->error->message ) ) ); } } return $result; }
[ "private", "function", "create_installs_with_user", "(", "FS_User", "$", "user", ",", "$", "license_key", "=", "false", ",", "$", "trial_plan_id", "=", "false", ",", "$", "sites", "=", "array", "(", ")", ",", "$", "redirect", "=", "false", ",", "$", "sil...
Initiate an API request to create a collection of installs. @author Vova Feldman (@svovaf) @since 2.0.0 @param \FS_User $user @param bool $license_key @param bool $trial_plan_id @param array $sites @param bool $redirect @param bool $silent @return object|mixed
[ "Initiate", "an", "API", "request", "to", "create", "a", "collection", "of", "installs", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14901-L14970
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._activate_addon_account
private function _activate_addon_account( Freemius $parent_fs ) { if ( $this->is_registered() ) { // Already activated. return; } // Activate add-on with parent plugin credentials. $addon_install = $parent_fs->get_api_site_scope()->call( "/addons/{$this->_plugin->id}/installs.json", 'post', $this->get_install_data_for_api( array( 'uid' => $this->get_anonymous_id(), ), false, false ) ); if ( isset( $addon_install->error ) ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' . $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...', 'error' ); return; } // Get user information based on parent's plugin. $user = $parent_fs->get_user(); // First of all, set site and user info - otherwise we won't // be able to invoke API calls. $this->_site = new FS_Site( $addon_install ); $this->_user = $user; // Sync add-on plans. $this->_sync_plans(); // Get site's current plan. //$this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id ); $this->_set_account( $user, $this->_site ); // Sync licenses. $this->_sync_licenses(); // Try to activate premium license. $this->_activate_license( true ); }
php
private function _activate_addon_account( Freemius $parent_fs ) { if ( $this->is_registered() ) { // Already activated. return; } // Activate add-on with parent plugin credentials. $addon_install = $parent_fs->get_api_site_scope()->call( "/addons/{$this->_plugin->id}/installs.json", 'post', $this->get_install_data_for_api( array( 'uid' => $this->get_anonymous_id(), ), false, false ) ); if ( isset( $addon_install->error ) ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' . $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...', 'error' ); return; } // Get user information based on parent's plugin. $user = $parent_fs->get_user(); // First of all, set site and user info - otherwise we won't // be able to invoke API calls. $this->_site = new FS_Site( $addon_install ); $this->_user = $user; // Sync add-on plans. $this->_sync_plans(); // Get site's current plan. //$this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id ); $this->_set_account( $user, $this->_site ); // Sync licenses. $this->_sync_licenses(); // Try to activate premium license. $this->_activate_license( true ); }
[ "private", "function", "_activate_addon_account", "(", "Freemius", "$", "parent_fs", ")", "{", "if", "(", "$", "this", "->", "is_registered", "(", ")", ")", "{", "// Already activated.\r", "return", ";", "}", "// Activate add-on with parent plugin credentials.\r", "$"...
Tries to activate add-on account based on parent plugin info. @author Vova Feldman (@svovaf) @since 1.0.6 @param Freemius $parent_fs
[ "Tries", "to", "activate", "add", "-", "on", "account", "based", "on", "parent", "plugin", "info", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L14980-L15027
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.activate_parent_account
private function activate_parent_account( Freemius $parent_fs ) { if ( ! $this->is_addon() ) { // This is not an add-on. return; } if ( $parent_fs->is_registered() ) { // Already activated. return; } // Activate parent with add-on's user credentials. $parent_install = $this->get_api_user_scope()->call( "/plugins/{$parent_fs->_plugin->id}/installs.json", 'post', $parent_fs->get_install_data_for_api( array( 'uid' => $parent_fs->get_anonymous_id(), ), false, false ) ); if ( isset( $parent_install->error ) ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' . $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $parent_install->error->message . '</b>', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...', 'error' ); return; } $parent_fs->_admin_notices->remove_sticky( 'connect_account' ); if ( $parent_fs->is_pending_activation() ) { $parent_fs->_admin_notices->remove_sticky( 'activation_pending' ); unset( $parent_fs->_storage->is_pending_activation ); } // Get user information based on parent's plugin. $user = $this->get_user(); // First of all, set site info - otherwise we won't // be able to invoke API calls. $parent_fs->_site = new FS_Site( $parent_install ); $parent_fs->_user = $user; // Sync add-on plans. $parent_fs->_sync_plans(); $parent_fs->_set_account( $user, $parent_fs->_site ); }
php
private function activate_parent_account( Freemius $parent_fs ) { if ( ! $this->is_addon() ) { // This is not an add-on. return; } if ( $parent_fs->is_registered() ) { // Already activated. return; } // Activate parent with add-on's user credentials. $parent_install = $this->get_api_user_scope()->call( "/plugins/{$parent_fs->_plugin->id}/installs.json", 'post', $parent_fs->get_install_data_for_api( array( 'uid' => $parent_fs->get_anonymous_id(), ), false, false ) ); if ( isset( $parent_install->error ) ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' . $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $parent_install->error->message . '</b>', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...', 'error' ); return; } $parent_fs->_admin_notices->remove_sticky( 'connect_account' ); if ( $parent_fs->is_pending_activation() ) { $parent_fs->_admin_notices->remove_sticky( 'activation_pending' ); unset( $parent_fs->_storage->is_pending_activation ); } // Get user information based on parent's plugin. $user = $this->get_user(); // First of all, set site info - otherwise we won't // be able to invoke API calls. $parent_fs->_site = new FS_Site( $parent_install ); $parent_fs->_user = $user; // Sync add-on plans. $parent_fs->_sync_plans(); $parent_fs->_set_account( $user, $parent_fs->_site ); }
[ "private", "function", "activate_parent_account", "(", "Freemius", "$", "parent_fs", ")", "{", "if", "(", "!", "$", "this", "->", "is_addon", "(", ")", ")", "{", "// This is not an add-on.\r", "return", ";", "}", "if", "(", "$", "parent_fs", "->", "is_regist...
Tries to activate parent account based on add-on's info. @author Vova Feldman (@svovaf) @since 1.2.2.7 @param Freemius $parent_fs
[ "Tries", "to", "activate", "parent", "account", "based", "on", "add", "-", "on", "s", "info", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15037-L15088
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.add_menu_action
private function add_menu_action() { if ( $this->is_activation_mode() ) { if ( $this->is_plugin() || ( $this->has_settings_menu() && ! $this->is_free_wp_org_theme() ) ) { $this->override_plugin_menu_with_activation(); } else { /** * Handle theme opt-in when the opt-in form shows as a dialog box in the themes page. */ if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) ) { add_action( 'load-themes.php', array( &$this, '_install_with_current_user' ) ); } else if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) || fs_request_get_bool( 'pending_activation' ) ) { add_action( 'load-themes.php', array( &$this, '_install_with_new_user' ) ); } } } else { if ( ! $this->is_registered() ) { // If not registered try to install user. if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) { $this->_install_with_new_user(); } } else if ( fs_request_is_action( 'sync_user' ) && ( ! $this->has_settings_menu() || $this->is_free_wp_org_theme() ) ) { $this->_handle_account_user_sync(); } } }
php
private function add_menu_action() { if ( $this->is_activation_mode() ) { if ( $this->is_plugin() || ( $this->has_settings_menu() && ! $this->is_free_wp_org_theme() ) ) { $this->override_plugin_menu_with_activation(); } else { /** * Handle theme opt-in when the opt-in form shows as a dialog box in the themes page. */ if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) ) { add_action( 'load-themes.php', array( &$this, '_install_with_current_user' ) ); } else if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) || fs_request_get_bool( 'pending_activation' ) ) { add_action( 'load-themes.php', array( &$this, '_install_with_new_user' ) ); } } } else { if ( ! $this->is_registered() ) { // If not registered try to install user. if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) { $this->_install_with_new_user(); } } else if ( fs_request_is_action( 'sync_user' ) && ( ! $this->has_settings_menu() || $this->is_free_wp_org_theme() ) ) { $this->_handle_account_user_sync(); } } }
[ "private", "function", "add_menu_action", "(", ")", "{", "if", "(", "$", "this", "->", "is_activation_mode", "(", ")", ")", "{", "if", "(", "$", "this", "->", "is_plugin", "(", ")", "||", "(", "$", "this", "->", "has_settings_menu", "(", ")", "&&", "...
Admin dashboard menu items modifications. NOTE: admin_menu action executed before admin_init. @author Vova Feldman (@svovaf) @since 1.0.7
[ "Admin", "dashboard", "menu", "items", "modifications", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15170-L15199
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.override_plugin_menu_with_activation
private function override_plugin_menu_with_activation() { $this->_logger->entrance(); $hook = false; if ( ! $this->has_settings_menu() ) { // Add the opt-in page without a menu item. $hook = FS_Admin_Menu_Manager::add_subpage( null, $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_slug, array( &$this, '_connect_page_render' ) ); } else if ( $this->_menu->is_top_level() ) { if ( $this->_menu->is_override_exact() ) { // Make sure the current page is matching the activation page. if ( ! $this->is_matching_url( $this->get_activation_url() ) ) { return; } } $hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) ); if ( false === $hook ) { // Create new menu item just for the opt-in. $hook = FS_Admin_Menu_Manager::add_page( $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->get_slug(), array( &$this, '_connect_page_render' ) ); } } else { $menus = array( $this->_menu->get_parent_slug() ); if ( $this->_menu->is_override_exact() ) { // Make sure the current page is matching the activation page. if ( ! $this->is_matching_url( $this->get_activation_url() ) ) { return; } } foreach ( $menus as $parent_slug ) { $hook = $this->_menu->override_submenu_action( $parent_slug, $this->_menu->get_raw_slug(), array( &$this, '_connect_page_render' ) ); if ( false !== $hook ) { // Found plugin's submenu item. break; } } } if ( $this->is_activation_page() ) { // Clean admin page from distracting content. self::_clean_admin_content_section(); } if ( false !== $hook ) { if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) ) { $this->_install_with_current_user(); } else if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) { $this->_install_with_new_user(); } } }
php
private function override_plugin_menu_with_activation() { $this->_logger->entrance(); $hook = false; if ( ! $this->has_settings_menu() ) { // Add the opt-in page without a menu item. $hook = FS_Admin_Menu_Manager::add_subpage( null, $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_slug, array( &$this, '_connect_page_render' ) ); } else if ( $this->_menu->is_top_level() ) { if ( $this->_menu->is_override_exact() ) { // Make sure the current page is matching the activation page. if ( ! $this->is_matching_url( $this->get_activation_url() ) ) { return; } } $hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) ); if ( false === $hook ) { // Create new menu item just for the opt-in. $hook = FS_Admin_Menu_Manager::add_page( $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->get_slug(), array( &$this, '_connect_page_render' ) ); } } else { $menus = array( $this->_menu->get_parent_slug() ); if ( $this->_menu->is_override_exact() ) { // Make sure the current page is matching the activation page. if ( ! $this->is_matching_url( $this->get_activation_url() ) ) { return; } } foreach ( $menus as $parent_slug ) { $hook = $this->_menu->override_submenu_action( $parent_slug, $this->_menu->get_raw_slug(), array( &$this, '_connect_page_render' ) ); if ( false !== $hook ) { // Found plugin's submenu item. break; } } } if ( $this->is_activation_page() ) { // Clean admin page from distracting content. self::_clean_admin_content_section(); } if ( false !== $hook ) { if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) ) { $this->_install_with_current_user(); } else if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) { $this->_install_with_new_user(); } } }
[ "private", "function", "override_plugin_menu_with_activation", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "hook", "=", "false", ";", "if", "(", "!", "$", "this", "->", "has_settings_menu", "(", ")", ")", "{", "// A...
Remove plugin's all admin menu items & pages, and replace with activation page. @author Vova Feldman (@svovaf) @since 1.0.1
[ "Remove", "plugin", "s", "all", "admin", "menu", "items", "&", "pages", "and", "replace", "with", "activation", "page", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15232-L15303
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.add_network_menu_when_missing
private function add_network_menu_when_missing() { $this->_logger->entrance(); if ( ! $this->_is_network_active ) { // Plugin wasn't activated on the network level. return; } if ( ! fs_is_network_admin() ) { // The context is not the network admin. return; } if ( $this->_menu->has_network_menu() ) { // Plugin already has a network level menu. return; } if ( $this->is_network_activation_mode() ) { /** * Do not add during activation mode, otherwise, there will be duplicate menus while the opt-in * screen is being shown. * * @author Leo Fajardo (@leorw) */ return; } if ( ! WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED ) { if ( $this->is_network_delegated_connection() ) { // Super-admin delegated the connection to the site admins. return; } } if ( ! $this->_menu->has_menu() || $this->_menu->is_top_level() ) { $this->_dynamically_added_top_level_page_hook_name = $this->_menu->add_page_and_update( $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->has_menu() ? $this->_menu->get_slug() : $this->_slug ); } else { $this->_menu->add_subpage_and_update( $this->_menu->get_parent_slug(), $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->get_slug() ); } }
php
private function add_network_menu_when_missing() { $this->_logger->entrance(); if ( ! $this->_is_network_active ) { // Plugin wasn't activated on the network level. return; } if ( ! fs_is_network_admin() ) { // The context is not the network admin. return; } if ( $this->_menu->has_network_menu() ) { // Plugin already has a network level menu. return; } if ( $this->is_network_activation_mode() ) { /** * Do not add during activation mode, otherwise, there will be duplicate menus while the opt-in * screen is being shown. * * @author Leo Fajardo (@leorw) */ return; } if ( ! WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED ) { if ( $this->is_network_delegated_connection() ) { // Super-admin delegated the connection to the site admins. return; } } if ( ! $this->_menu->has_menu() || $this->_menu->is_top_level() ) { $this->_dynamically_added_top_level_page_hook_name = $this->_menu->add_page_and_update( $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->has_menu() ? $this->_menu->get_slug() : $this->_slug ); } else { $this->_menu->add_subpage_and_update( $this->_menu->get_parent_slug(), $this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->get_slug() ); } }
[ "private", "function", "add_network_menu_when_missing", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "_is_network_active", ")", "{", "// Plugin wasn't activated on the network level.\r", "return", ...
If a plugin was network activated and connected but don't have a network level settings, then add an artificial menu item for the Account and other Freemius settings. @author Vova Feldman (@svovaf) @since 2.0.0
[ "If", "a", "plugin", "was", "network", "activated", "and", "connected", "but", "don", "t", "have", "a", "network", "level", "settings", "then", "add", "an", "artificial", "menu", "item", "for", "the", "Account", "and", "other", "Freemius", "settings", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15313-L15364
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.embed_submenu_items
private function embed_submenu_items() { $item_template = $this->_menu->is_top_level() ? '<span class="fs-submenu-item %s %s %s">%s</span>' : '<span class="fs-submenu-item fs-sub %s %s %s">%s</span>'; $top_level_menu_capability = $this->get_top_level_menu_capability(); ksort( $this->_menu_items ); $is_first_submenu_item = true; foreach ( $this->_menu_items as $priority => $items ) { foreach ( $items as $item ) { $capability = ( ! empty( $item['capability'] ) ? $item['capability'] : $top_level_menu_capability ); $menu_item = sprintf( $item_template, $this->get_unique_affix(), $item['menu_slug'], ! empty( $item['class'] ) ? $item['class'] : '', $item['menu_title'] ); $top_level_menu_slug = $this->get_top_level_menu_slug(); $menu_slug = $this->_menu->get_slug( $item['menu_slug'] ); if ( ! isset( $item['url'] ) ) { $hook = FS_Admin_Menu_Manager::add_subpage( $item['show_submenu'] ? $top_level_menu_slug : null, $item['page_title'], $menu_item, $capability, $menu_slug, $item['render_function'] ); if ( false !== $item['before_render_function'] ) { add_action( "load-$hook", $item['before_render_function'] ); } } else { FS_Admin_Menu_Manager::add_subpage( $item['show_submenu'] ? $top_level_menu_slug : null, $item['page_title'], $menu_item, $capability, $menu_slug, array( $this, '' ) ); } if ( $item['show_submenu'] && $is_first_submenu_item ) { if ( $this->_is_network_active && ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) { /** * If the top-level menu has been dynamically created, remove the first submenu item that * WordPress automatically creates when there's no submenu item whose slug matches the * parent's. In the following example, the `Awesome Plugin` submenu item will be removed. * * Awesome Plugin * - Awesome Plugin <-- we want to remove this since there's no real setting page for the top-level * * @author Leo Fajardo (@leorw) */ remove_submenu_page( $top_level_menu_slug, $top_level_menu_slug ); } $is_first_submenu_item = false; } } } }
php
private function embed_submenu_items() { $item_template = $this->_menu->is_top_level() ? '<span class="fs-submenu-item %s %s %s">%s</span>' : '<span class="fs-submenu-item fs-sub %s %s %s">%s</span>'; $top_level_menu_capability = $this->get_top_level_menu_capability(); ksort( $this->_menu_items ); $is_first_submenu_item = true; foreach ( $this->_menu_items as $priority => $items ) { foreach ( $items as $item ) { $capability = ( ! empty( $item['capability'] ) ? $item['capability'] : $top_level_menu_capability ); $menu_item = sprintf( $item_template, $this->get_unique_affix(), $item['menu_slug'], ! empty( $item['class'] ) ? $item['class'] : '', $item['menu_title'] ); $top_level_menu_slug = $this->get_top_level_menu_slug(); $menu_slug = $this->_menu->get_slug( $item['menu_slug'] ); if ( ! isset( $item['url'] ) ) { $hook = FS_Admin_Menu_Manager::add_subpage( $item['show_submenu'] ? $top_level_menu_slug : null, $item['page_title'], $menu_item, $capability, $menu_slug, $item['render_function'] ); if ( false !== $item['before_render_function'] ) { add_action( "load-$hook", $item['before_render_function'] ); } } else { FS_Admin_Menu_Manager::add_subpage( $item['show_submenu'] ? $top_level_menu_slug : null, $item['page_title'], $menu_item, $capability, $menu_slug, array( $this, '' ) ); } if ( $item['show_submenu'] && $is_first_submenu_item ) { if ( $this->_is_network_active && ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) { /** * If the top-level menu has been dynamically created, remove the first submenu item that * WordPress automatically creates when there's no submenu item whose slug matches the * parent's. In the following example, the `Awesome Plugin` submenu item will be removed. * * Awesome Plugin * - Awesome Plugin <-- we want to remove this since there's no real setting page for the top-level * * @author Leo Fajardo (@leorw) */ remove_submenu_page( $top_level_menu_slug, $top_level_menu_slug ); } $is_first_submenu_item = false; } } } }
[ "private", "function", "embed_submenu_items", "(", ")", "{", "$", "item_template", "=", "$", "this", "->", "_menu", "->", "is_top_level", "(", ")", "?", "'<span class=\"fs-submenu-item %s %s %s\">%s</span>'", ":", "'<span class=\"fs-submenu-item fs-sub %s %s %s\">%s</span>'",...
Moved the actual submenu item additions to a separated function, in order to support sub-submenu items when the plugin's settings only have a submenu and not top-level menu item. @author Vova Feldman (@svovaf) @since 1.1.4
[ "Moved", "the", "actual", "submenu", "item", "additions", "to", "a", "separated", "function", "in", "order", "to", "support", "sub", "-", "submenu", "items", "when", "the", "plugin", "s", "settings", "only", "have", "a", "submenu", "and", "not", "top", "-"...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15616-L15689
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.order_sub_submenu_items
private function order_sub_submenu_items() { global $submenu; $menu_slug = $this->_menu->get_top_level_menu_slug(); /** * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us, * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission. * * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu * of another plugin, only users that have the right role can access its sub-submenus since we will use the * capability needed to access the parent menu as the capability for the submenus that we will add. */ if ( empty( $submenu[ $menu_slug ] ) ) { return; } $top_level_menu = &$submenu[ $menu_slug ]; $all_submenu_items_after = array(); $found_submenu_item = false; foreach ( $top_level_menu as $submenu_id => $meta ) { if ( $found_submenu_item ) { // Remove all submenu items after the plugin's submenu item. $all_submenu_items_after[] = $meta; unset( $top_level_menu[ $submenu_id ] ); } if ( $this->_menu->get_raw_slug() === $meta[2] ) { // Found the submenu item, put all below. $found_submenu_item = true; continue; } } // Embed all plugin's new submenu items. $this->embed_submenu_items(); // Start with specially high number to make sure it's appended. $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 ); foreach ( $all_submenu_items_after as $meta ) { $top_level_menu[ $i ] = $meta; $i ++; } // Sort submenu items. ksort( $top_level_menu ); }
php
private function order_sub_submenu_items() { global $submenu; $menu_slug = $this->_menu->get_top_level_menu_slug(); /** * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us, * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission. * * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu * of another plugin, only users that have the right role can access its sub-submenus since we will use the * capability needed to access the parent menu as the capability for the submenus that we will add. */ if ( empty( $submenu[ $menu_slug ] ) ) { return; } $top_level_menu = &$submenu[ $menu_slug ]; $all_submenu_items_after = array(); $found_submenu_item = false; foreach ( $top_level_menu as $submenu_id => $meta ) { if ( $found_submenu_item ) { // Remove all submenu items after the plugin's submenu item. $all_submenu_items_after[] = $meta; unset( $top_level_menu[ $submenu_id ] ); } if ( $this->_menu->get_raw_slug() === $meta[2] ) { // Found the submenu item, put all below. $found_submenu_item = true; continue; } } // Embed all plugin's new submenu items. $this->embed_submenu_items(); // Start with specially high number to make sure it's appended. $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 ); foreach ( $all_submenu_items_after as $meta ) { $top_level_menu[ $i ] = $meta; $i ++; } // Sort submenu items. ksort( $top_level_menu ); }
[ "private", "function", "order_sub_submenu_items", "(", ")", "{", "global", "$", "submenu", ";", "$", "menu_slug", "=", "$", "this", "->", "_menu", "->", "get_top_level_menu_slug", "(", ")", ";", "/**\r\n * Before \"admin_menu\" fires, WordPress will loop over ...
Re-order the submenu items so all Freemius added new submenu items are added right after the plugin's settings submenu item. @author Vova Feldman (@svovaf) @since 1.1.4
[ "Re", "-", "order", "the", "submenu", "items", "so", "all", "Freemius", "added", "new", "submenu", "items", "are", "added", "right", "after", "the", "plugin", "s", "settings", "submenu", "item", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15698-L15749
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._add_default_submenu_items
function _add_default_submenu_items() { if ( ! $this->is_on() ) { return; } if ( ! $this->is_activation_mode() && ( ( $this->_is_network_active && fs_is_network_admin() ) || ( ! $this->_is_network_active && is_admin() ) ) ) { $this->add_submenu_link_item( $this->apply_filters( 'support_forum_submenu', $this->get_text_inline( 'Support Forum', 'support-forum' ) ), $this->get_support_forum_url(), 'wp-support-forum', null, 50, $this->is_submenu_item_visible( 'support' ) ); } }
php
function _add_default_submenu_items() { if ( ! $this->is_on() ) { return; } if ( ! $this->is_activation_mode() && ( ( $this->_is_network_active && fs_is_network_admin() ) || ( ! $this->_is_network_active && is_admin() ) ) ) { $this->add_submenu_link_item( $this->apply_filters( 'support_forum_submenu', $this->get_text_inline( 'Support Forum', 'support-forum' ) ), $this->get_support_forum_url(), 'wp-support-forum', null, 50, $this->is_submenu_item_visible( 'support' ) ); } }
[ "function", "_add_default_submenu_items", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_on", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "is_activation_mode", "(", ")", "&&", "(", "(", "$", "this", "->", "_is_...
Displays the Support Forum link when enabled. Can be filtered like so: function _fs_show_support_menu( $is_visible, $menu_id ) { if ( 'support' === $menu_id ) { return _fs->is_registered(); } return $is_visible; } _fs()->add_filter('is_submenu_visible', '_fs_show_support_menu', 10, 2);
[ "Displays", "the", "Support", "Forum", "link", "when", "enabled", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15777-L15795
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.get_module_unique_affix
static function get_module_unique_affix( $slug, $is_plugin = true ) { $affix = $slug; if ( ! $is_plugin ) { $affix .= '-' . WP_FS__MODULE_TYPE_THEME; } return $affix; }
php
static function get_module_unique_affix( $slug, $is_plugin = true ) { $affix = $slug; if ( ! $is_plugin ) { $affix .= '-' . WP_FS__MODULE_TYPE_THEME; } return $affix; }
[ "static", "function", "get_module_unique_affix", "(", "$", "slug", ",", "$", "is_plugin", "=", "true", ")", "{", "$", "affix", "=", "$", "slug", ";", "if", "(", "!", "$", "is_plugin", ")", "{", "$", "affix", ".=", "'-'", ".", "WP_FS__MODULE_TYPE_THEME", ...
Returns a string that can be used to generate a unique action name, option name, HTML element ID, or HTML element class. @author Vova Feldman (@svovaf) @since 1.2.2.5 @param string $slug @param bool $is_plugin @return string
[ "Returns", "a", "string", "that", "can", "be", "used", "to", "generate", "a", "unique", "action", "name", "option", "name", "HTML", "element", "ID", "or", "HTML", "element", "class", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L15978-L15986
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.do_action
function do_action( $tag, $arg = '' ) { $this->_logger->entrance( $tag ); $args = func_get_args(); call_user_func_array( 'do_action', array_merge( array( $this->get_action_tag( $tag ) ), array_slice( $args, 1 ) ) ); }
php
function do_action( $tag, $arg = '' ) { $this->_logger->entrance( $tag ); $args = func_get_args(); call_user_func_array( 'do_action', array_merge( array( $this->get_action_tag( $tag ) ), array_slice( $args, 1 ) ) ); }
[ "function", "do_action", "(", "$", "tag", ",", "$", "arg", "=", "''", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "tag", ")", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "call_user_func_array", "(", "'do_action'", "...
Do action, specific for the current context plugin. @author Vova Feldman (@svovaf) @since 1.0.1 @param string $tag The name of the action to be executed. @param mixed $arg,... Optional. Additional arguments which are passed on to the functions hooked to the action. Default empty. @uses do_action()
[ "Do", "action", "specific", "for", "the", "current", "context", "plugin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16057-L16066
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.add_ajax_action
function add_ajax_action( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY ) { $this->_logger->entrance( $tag ); return self::add_ajax_action_static( $tag, $function_to_add, $priority, $this->_module_id ); }
php
function add_ajax_action( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY ) { $this->_logger->entrance( $tag ); return self::add_ajax_action_static( $tag, $function_to_add, $priority, $this->_module_id ); }
[ "function", "add_ajax_action", "(", "$", "tag", ",", "$", "function_to_add", ",", "$", "priority", "=", "WP_FS__DEFAULT_PRIORITY", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "tag", ")", ";", "return", "self", "::", "add_ajax_action_s...
Add AJAX action, specific for the current context plugin. @author Vova Feldman (@svovaf) @since 1.2.1 @param string $tag @param callable $function_to_add @param int $priority @uses add_action() @return bool True if action added, false if no need to add the action since the AJAX call isn't matching.
[ "Add", "AJAX", "action", "specific", "for", "the", "current", "context", "plugin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16106-L16119
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.add_ajax_action_static
static function add_ajax_action_static( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $module_id = null ) { self::$_static_logger->entrance( $tag ); if ( ! self::is_ajax_action_static( $tag, $module_id ) ) { return false; } add_action( 'wp_ajax_' . self::get_ajax_action_static( $tag, $module_id ), $function_to_add, $priority, 0 ); self::$_static_logger->info( "$tag AJAX callback action added." ); return true; }
php
static function add_ajax_action_static( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $module_id = null ) { self::$_static_logger->entrance( $tag ); if ( ! self::is_ajax_action_static( $tag, $module_id ) ) { return false; } add_action( 'wp_ajax_' . self::get_ajax_action_static( $tag, $module_id ), $function_to_add, $priority, 0 ); self::$_static_logger->info( "$tag AJAX callback action added." ); return true; }
[ "static", "function", "add_ajax_action_static", "(", "$", "tag", ",", "$", "function_to_add", ",", "$", "priority", "=", "WP_FS__DEFAULT_PRIORITY", ",", "$", "module_id", "=", "null", ")", "{", "self", "::", "$", "_static_logger", "->", "entrance", "(", "$", ...
Add AJAX action. @author Vova Feldman (@svovaf) @since 1.2.1.6 @param string $tag @param callable $function_to_add @param int $priority @param number|null $module_id @return bool True if action added, false if no need to add the action since the AJAX call isn't matching. @uses add_action()
[ "Add", "AJAX", "action", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16136-L16158
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.shoot_ajax_failure
static function shoot_ajax_failure( $error = '' ) { $result = array( 'success' => false ); if ( ! empty( $error ) ) { $result['error'] = $error; } wp_send_json( $result ); }
php
static function shoot_ajax_failure( $error = '' ) { $result = array( 'success' => false ); if ( ! empty( $error ) ) { $result['error'] = $error; } wp_send_json( $result ); }
[ "static", "function", "shoot_ajax_failure", "(", "$", "error", "=", "''", ")", "{", "$", "result", "=", "array", "(", "'success'", "=>", "false", ")", ";", "if", "(", "!", "empty", "(", "$", "error", ")", ")", "{", "$", "result", "[", "'error'", "]...
Send a JSON response back to an Ajax request, indicating failure. @author Vova Feldman (@svovaf) @since 1.2.1.5 @param mixed $error Optional error message.
[ "Send", "a", "JSON", "response", "back", "to", "an", "Ajax", "request", "indicating", "failure", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16192-L16199
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.apply_filters
function apply_filters( $tag, $value ) { $this->_logger->entrance( $tag ); $args = func_get_args(); array_unshift( $args, $this->get_unique_affix() ); return call_user_func_array( 'fs_apply_filter', $args ); }
php
function apply_filters( $tag, $value ) { $this->_logger->entrance( $tag ); $args = func_get_args(); array_unshift( $args, $this->get_unique_affix() ); return call_user_func_array( 'fs_apply_filter', $args ); }
[ "function", "apply_filters", "(", "$", "tag", ",", "$", "value", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "tag", ")", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "array_unshift", "(", "$", "args", ",", "$", "th...
Apply filter, specific for the current context plugin. @author Vova Feldman (@svovaf) @since 1.0.9 @param string $tag The name of the filter hook. @param mixed $value The value on which the filters hooked to `$tag` are applied on. @return mixed The filtered value after all hooked functions are applied to it. @uses apply_filters()
[ "Apply", "filter", "specific", "for", "the", "current", "context", "plugin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16214-L16221
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.add_filter
function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) { $this->_logger->entrance( $tag ); add_filter( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args ); }
php
function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) { $this->_logger->entrance( $tag ); add_filter( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args ); }
[ "function", "add_filter", "(", "$", "tag", ",", "$", "function_to_add", ",", "$", "priority", "=", "WP_FS__DEFAULT_PRIORITY", ",", "$", "accepted_args", "=", "1", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "tag", ")", ";", "add_f...
Add filter, specific for the current context plugin. @author Vova Feldman (@svovaf) @since 1.0.9 @param string $tag @param callable $function_to_add @param int $priority @param int $accepted_args @uses add_filter()
[ "Add", "filter", "specific", "for", "the", "current", "context", "plugin", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16236-L16240
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_filter
function has_filter( $tag, $function_to_check = false ) { $this->_logger->entrance( $tag ); return has_filter( $this->get_action_tag( $tag ), $function_to_check ); }
php
function has_filter( $tag, $function_to_check = false ) { $this->_logger->entrance( $tag ); return has_filter( $this->get_action_tag( $tag ), $function_to_check ); }
[ "function", "has_filter", "(", "$", "tag", ",", "$", "function_to_check", "=", "false", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", "$", "tag", ")", ";", "return", "has_filter", "(", "$", "this", "->", "get_action_tag", "(", "$", "ta...
Check if has filter. @author Vova Feldman (@svovaf) @since 1.1.4 @param string $tag @param callable|bool $function_to_check Optional. The callback to check for. Default false. @return false|int @uses has_filter()
[ "Check", "if", "has", "filter", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16255-L16259
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._store_site
private function _store_site( $store = true, $network_level_or_blog_id = null, FS_Site $site = null ) { $this->_logger->entrance(); if ( empty( $this->_site->id ) ) { $this->_logger->error( "Empty install ID, can't store site." ); return; } $site_clone = is_object( $site ) ? $site : $this->_site; $encrypted_site = clone $site_clone; $sites = self::get_all_sites( $this->_module_type, $network_level_or_blog_id ); $prev_stored_user_id = $this->_storage->get( 'prev_user_id', false, $network_level_or_blog_id ); if ( empty( $prev_stored_user_id ) && $this->_user->id != $this->_site->user_id ) { /** * Store the current user ID as the previous user ID so that the previous user can be used * as the install's owner while the new owner's details are not yet available. * * This will be executed only in the `replica` site. For example, there are 2 sites, namely `original` * and `replica`, then an ownership change was initiated and completed in the `original`, the `replica` * will be using the previous user until it is updated again (e.g.: until the next clone of `original` * into `replica`. * * @author Leo Fajardo (@leorw) */ $this->_storage->store( 'prev_user_id', $sites[ $this->_slug ]->user_id, $network_level_or_blog_id ); } $sites[ $this->_slug ] = $encrypted_site; $this->set_account_option( 'sites', $sites, $store, $network_level_or_blog_id ); }
php
private function _store_site( $store = true, $network_level_or_blog_id = null, FS_Site $site = null ) { $this->_logger->entrance(); if ( empty( $this->_site->id ) ) { $this->_logger->error( "Empty install ID, can't store site." ); return; } $site_clone = is_object( $site ) ? $site : $this->_site; $encrypted_site = clone $site_clone; $sites = self::get_all_sites( $this->_module_type, $network_level_or_blog_id ); $prev_stored_user_id = $this->_storage->get( 'prev_user_id', false, $network_level_or_blog_id ); if ( empty( $prev_stored_user_id ) && $this->_user->id != $this->_site->user_id ) { /** * Store the current user ID as the previous user ID so that the previous user can be used * as the install's owner while the new owner's details are not yet available. * * This will be executed only in the `replica` site. For example, there are 2 sites, namely `original` * and `replica`, then an ownership change was initiated and completed in the `original`, the `replica` * will be using the previous user until it is updated again (e.g.: until the next clone of `original` * into `replica`. * * @author Leo Fajardo (@leorw) */ $this->_storage->store( 'prev_user_id', $sites[ $this->_slug ]->user_id, $network_level_or_blog_id ); } $sites[ $this->_slug ] = $encrypted_site; $this->set_account_option( 'sites', $sites, $store, $network_level_or_blog_id ); }
[ "private", "function", "_store_site", "(", "$", "store", "=", "true", ",", "$", "network_level_or_blog_id", "=", "null", ",", "FS_Site", "$", "site", "=", "null", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "empt...
Update site information. @author Vova Feldman (@svovaf) @since 1.0.1 @param bool $store Flush to Database if true. @param null|int $network_level_or_blog_id Since 2.0.0 @param \FS_Site $site Since 2.0.0
[ "Update", "site", "information", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16289-L16325
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._store_plans
private function _store_plans( $store = true ) { $this->_logger->entrance(); $plans = self::get_all_plans( $this->_module_type ); // Copy plans. $encrypted_plans = array(); for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) { $encrypted_plans[] = self::_encrypt_entity( $this->_plans[ $i ] ); } $plans[ $this->_slug ] = $encrypted_plans; $this->set_account_option( 'plans', $plans, $store ); }
php
private function _store_plans( $store = true ) { $this->_logger->entrance(); $plans = self::get_all_plans( $this->_module_type ); // Copy plans. $encrypted_plans = array(); for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) { $encrypted_plans[] = self::_encrypt_entity( $this->_plans[ $i ] ); } $plans[ $this->_slug ] = $encrypted_plans; $this->set_account_option( 'plans', $plans, $store ); }
[ "private", "function", "_store_plans", "(", "$", "store", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "plans", "=", "self", "::", "get_all_plans", "(", "$", "this", "->", "_module_type", ")", ";", "// Copy...
Update plugin's plans information. @author Vova Feldman (@svovaf) @since 1.0.2 @param bool $store Flush to Database if true.
[ "Update", "plugin", "s", "plans", "information", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16335-L16349
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._store_licenses
private function _store_licenses( $store = true, $module_id = false, $licenses = array() ) { $this->_logger->entrance(); $all_licenses = self::get_all_licenses(); if ( ! FS_Plugin::is_valid_id( $module_id ) ) { $module_id = $this->_module_id; $user_licenses = is_array( $this->_licenses ) ? $this->_licenses : array(); if ( empty( $user_licenses ) ) { // If the context user doesn't have any license, don't update the licenses collection. return; } $new_user_licenses_map = array(); foreach ( $user_licenses as $user_license ) { $new_user_licenses_map[ $user_license->id ] = $user_license; } self::store_user_id_license_ids_map( array_keys( $new_user_licenses_map ), $this->_module_id, $this->_user->id ); // Update user licenses. $licenses_to_update_count = count( $new_user_licenses_map ); foreach ( $all_licenses[ $module_id ] as $key => $license ) { if ( 0 === $licenses_to_update_count ) { break; } if ( isset( $new_user_licenses_map[ $license->id ] ) ) { // Update license. $all_licenses[ $module_id ][ $key ] = $new_user_licenses_map[ $license->id ]; unset( $new_user_licenses_map[ $license->id ] ); $licenses_to_update_count --; } } if ( ! empty( $new_user_licenses_map ) ) { // Add new licenses. $all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] ); } $licenses = $all_licenses[ $module_id ]; } if ( ! isset( $all_licenses[ $module_id ] ) ) { $all_licenses[ $module_id ] = array(); } $all_licenses[ $module_id ] = $licenses; self::$_accounts->set_option( 'all_licenses', $all_licenses, $store ); }
php
private function _store_licenses( $store = true, $module_id = false, $licenses = array() ) { $this->_logger->entrance(); $all_licenses = self::get_all_licenses(); if ( ! FS_Plugin::is_valid_id( $module_id ) ) { $module_id = $this->_module_id; $user_licenses = is_array( $this->_licenses ) ? $this->_licenses : array(); if ( empty( $user_licenses ) ) { // If the context user doesn't have any license, don't update the licenses collection. return; } $new_user_licenses_map = array(); foreach ( $user_licenses as $user_license ) { $new_user_licenses_map[ $user_license->id ] = $user_license; } self::store_user_id_license_ids_map( array_keys( $new_user_licenses_map ), $this->_module_id, $this->_user->id ); // Update user licenses. $licenses_to_update_count = count( $new_user_licenses_map ); foreach ( $all_licenses[ $module_id ] as $key => $license ) { if ( 0 === $licenses_to_update_count ) { break; } if ( isset( $new_user_licenses_map[ $license->id ] ) ) { // Update license. $all_licenses[ $module_id ][ $key ] = $new_user_licenses_map[ $license->id ]; unset( $new_user_licenses_map[ $license->id ] ); $licenses_to_update_count --; } } if ( ! empty( $new_user_licenses_map ) ) { // Add new licenses. $all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] ); } $licenses = $all_licenses[ $module_id ]; } if ( ! isset( $all_licenses[ $module_id ] ) ) { $all_licenses[ $module_id ] = array(); } $all_licenses[ $module_id ] = $licenses; self::$_accounts->set_option( 'all_licenses', $all_licenses, $store ); }
[ "private", "function", "_store_licenses", "(", "$", "store", "=", "true", ",", "$", "module_id", "=", "false", ",", "$", "licenses", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "all_licenses", ...
Update user's plugin licenses. @author Vova Feldman (@svovaf) @since 1.0.5 @param bool $store @param number|bool $module_id @param FS_Plugin_License[] $licenses
[ "Update", "user", "s", "plugin", "licenses", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16361-L16416
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._store_user
private function _store_user( $store = true ) { $this->_logger->entrance(); if ( empty( $this->_user->id ) ) { $this->_logger->error( "Empty user ID, can't store user." ); return; } $users = self::get_all_users(); $users[ $this->_user->id ] = $this->_user; self::$_accounts->set_option( 'users', $users, $store ); }
php
private function _store_user( $store = true ) { $this->_logger->entrance(); if ( empty( $this->_user->id ) ) { $this->_logger->error( "Empty user ID, can't store user." ); return; } $users = self::get_all_users(); $users[ $this->_user->id ] = $this->_user; self::$_accounts->set_option( 'users', $users, $store ); }
[ "private", "function", "_store_user", "(", "$", "store", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "_user", "->", "id", ")", ")", "{", "$", "this", "->", "_lo...
Update user information. @author Vova Feldman (@svovaf) @since 1.0.1 @param bool $store Flush to Database if true.
[ "Update", "user", "information", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16426-L16438
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._delete_account_addons
private function _delete_account_addons( $store = true ) { $all_addons = self::get_all_account_addons(); if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) { return false; } unset( $all_addons[ $this->_plugin->id ] ); self::$_accounts->set_option( 'account_addons', $all_addons, $store ); return true; }
php
private function _delete_account_addons( $store = true ) { $all_addons = self::get_all_account_addons(); if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) { return false; } unset( $all_addons[ $this->_plugin->id ] ); self::$_accounts->set_option( 'account_addons', $all_addons, $store ); return true; }
[ "private", "function", "_delete_account_addons", "(", "$", "store", "=", "true", ")", "{", "$", "all_addons", "=", "self", "::", "get_all_account_addons", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "all_addons", "[", "$", "this", "->", "_plugin", ...
Delete plugin's associated add-ons. @author Vova Feldman (@svovaf) @since 1.0.8 @param bool $store @return bool
[ "Delete", "plugin", "s", "associated", "add", "-", "ons", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16493-L16505
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._store_account_addons
private function _store_account_addons( $addons, $store = true ) { $this->_logger->entrance(); $all_addons = self::get_all_account_addons(); $all_addons[ $this->_plugin->id ] = $addons; self::$_accounts->set_option( 'account_addons', $all_addons, $store ); }
php
private function _store_account_addons( $addons, $store = true ) { $this->_logger->entrance(); $all_addons = self::get_all_account_addons(); $all_addons[ $this->_plugin->id ] = $addons; self::$_accounts->set_option( 'account_addons', $all_addons, $store ); }
[ "private", "function", "_store_account_addons", "(", "$", "addons", ",", "$", "store", "=", "true", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "all_addons", "=", "self", "::", "get_all_account_addons", "(", ")", ";", "$...
Update account add-ons list. @author Vova Feldman (@svovaf) @since 1.0.6 @param FS_Plugin[] $addons @param bool $store Flush to Database if true.
[ "Update", "account", "add", "-", "ons", "list", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16516-L16522
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._store_account
private function _store_account( $blog_id = null ) { $this->_logger->entrance(); $this->_store_site( false, $blog_id ); $this->_store_user( false ); $this->_store_plans( false ); $this->_store_licenses( false ); self::$_accounts->store( $blog_id ); }
php
private function _store_account( $blog_id = null ) { $this->_logger->entrance(); $this->_store_site( false, $blog_id ); $this->_store_user( false ); $this->_store_plans( false ); $this->_store_licenses( false ); self::$_accounts->store( $blog_id ); }
[ "private", "function", "_store_account", "(", "$", "blog_id", "=", "null", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "this", "->", "_store_site", "(", "false", ",", "$", "blog_id", ")", ";", "$", "this", "->", "_st...
Store account params in the Database. @author Vova Feldman (@svovaf) @since 1.0.1 @param null|int $blog_id Since 2.0.0
[ "Store", "account", "params", "in", "the", "Database", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16532-L16541
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._handle_account_user_sync
private function _handle_account_user_sync() { $this->_logger->entrance(); $api = $this->get_api_user_scope(); // Get user's information. $user = $api->get( '/', true ); if ( isset( $user->id ) ) { $this->_user->first = $user->first; $this->_user->last = $user->last; $this->_user->email = $user->email; $is_menu_item_account_visible = $this->is_submenu_item_visible( 'account' ); if ( $user->is_verified && ( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified ) ) { $this->_user->is_verified = true; $this->do_action( 'account_email_verified', $user->email ); $this->_admin_notices->add( $this->get_text_inline( 'Your email has been successfully verified - you are AWESOME!', 'email-verified-message' ), $this->get_text_x_inline( 'Right on', 'a positive response', 'right-on' ) . '!', 'success', // Make admin sticky if account menu item is invisible, // since the page will be auto redirected to the plugin's // main settings page, and the non-sticky message // will disappear. ! $is_menu_item_account_visible, 'email_verified' ); } // Flush user details to DB. $this->_store_user(); $this->do_action( 'after_account_user_sync', $user ); /** * If account menu item is hidden, redirect to plugin's main settings page. * * @author Vova Feldman (@svovaf) * @since 1.1.6 * * @link https://github.com/Freemius/wordpress-sdk/issues/6 */ if ( ! $is_menu_item_account_visible ) { fs_redirect( $this->_get_admin_page_url() ); } } }
php
private function _handle_account_user_sync() { $this->_logger->entrance(); $api = $this->get_api_user_scope(); // Get user's information. $user = $api->get( '/', true ); if ( isset( $user->id ) ) { $this->_user->first = $user->first; $this->_user->last = $user->last; $this->_user->email = $user->email; $is_menu_item_account_visible = $this->is_submenu_item_visible( 'account' ); if ( $user->is_verified && ( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified ) ) { $this->_user->is_verified = true; $this->do_action( 'account_email_verified', $user->email ); $this->_admin_notices->add( $this->get_text_inline( 'Your email has been successfully verified - you are AWESOME!', 'email-verified-message' ), $this->get_text_x_inline( 'Right on', 'a positive response', 'right-on' ) . '!', 'success', // Make admin sticky if account menu item is invisible, // since the page will be auto redirected to the plugin's // main settings page, and the non-sticky message // will disappear. ! $is_menu_item_account_visible, 'email_verified' ); } // Flush user details to DB. $this->_store_user(); $this->do_action( 'after_account_user_sync', $user ); /** * If account menu item is hidden, redirect to plugin's main settings page. * * @author Vova Feldman (@svovaf) * @since 1.1.6 * * @link https://github.com/Freemius/wordpress-sdk/issues/6 */ if ( ! $is_menu_item_account_visible ) { fs_redirect( $this->_get_admin_page_url() ); } } }
[ "private", "function", "_handle_account_user_sync", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "api", "=", "$", "this", "->", "get_api_user_scope", "(", ")", ";", "// Get user's information.\r", "$", "user", "=", "$", ...
Sync user's information. @author Vova Feldman (@svovaf) @since 1.0.3 @uses FS_Api
[ "Sync", "user", "s", "information", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16550-L16602
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_active_license
function has_active_license() { return ( is_object( $this->_license ) && is_numeric( $this->_license->id ) && ! $this->_license->is_expired() ); }
php
function has_active_license() { return ( is_object( $this->_license ) && is_numeric( $this->_license->id ) && ! $this->_license->is_expired() ); }
[ "function", "has_active_license", "(", ")", "{", "return", "(", "is_object", "(", "$", "this", "->", "_license", ")", "&&", "is_numeric", "(", "$", "this", "->", "_license", "->", "id", ")", "&&", "!", "$", "this", "->", "_license", "->", "is_expired", ...
Check if site assigned with active license. @author Vova Feldman (@svovaf) @since 1.0.6 @deprecated Please use has_active_valid_license() instead because license can be cancelled.
[ "Check", "if", "site", "assigned", "with", "active", "license", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L16984-L16990
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_any_active_valid_license
function has_any_active_valid_license() { if ( ! fs_is_network_admin() ) { return $this->has_active_valid_license(); } $installs = $this->get_blog_install_map(); $all_plugin_licenses = self::get_all_licenses( $this->_module_id ); foreach ( $installs as $blog_id => $install ) { if ( ! FS_Plugin_License::is_valid_id( $install->license_id ) ) { continue; } foreach ( $all_plugin_licenses as $license ) { if ( $license->id == $install->license_id ) { if ( self::is_active_valid_license( $license ) ) { return true; } } } } return false; }
php
function has_any_active_valid_license() { if ( ! fs_is_network_admin() ) { return $this->has_active_valid_license(); } $installs = $this->get_blog_install_map(); $all_plugin_licenses = self::get_all_licenses( $this->_module_id ); foreach ( $installs as $blog_id => $install ) { if ( ! FS_Plugin_License::is_valid_id( $install->license_id ) ) { continue; } foreach ( $all_plugin_licenses as $license ) { if ( $license->id == $install->license_id ) { if ( self::is_active_valid_license( $license ) ) { return true; } } } } return false; }
[ "function", "has_any_active_valid_license", "(", ")", "{", "if", "(", "!", "fs_is_network_admin", "(", ")", ")", "{", "return", "$", "this", "->", "has_active_valid_license", "(", ")", ";", "}", "$", "installs", "=", "$", "this", "->", "get_blog_install_map", ...
Checks if there's any site that is associated with an active & valid license. This logic is used to determine if the admin can download the premium code base from a network level admin. @author Vova Feldman (@svovaf) @since 2.1.3 @return bool
[ "Checks", "if", "there", "s", "any", "site", "that", "is", "associated", "with", "an", "active", "&", "valid", "license", ".", "This", "logic", "is", "used", "to", "determine", "if", "the", "admin", "can", "download", "the", "premium", "code", "base", "f...
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L17030-L17053
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.has_features_enabled_license
function has_features_enabled_license() { return ( is_object( $this->_license ) && is_numeric( $this->_license->id ) && $this->_license->is_features_enabled() ); }
php
function has_features_enabled_license() { return ( is_object( $this->_license ) && is_numeric( $this->_license->id ) && $this->_license->is_features_enabled() ); }
[ "function", "has_features_enabled_license", "(", ")", "{", "return", "(", "is_object", "(", "$", "this", "->", "_license", ")", "&&", "is_numeric", "(", "$", "this", "->", "_license", "->", "id", ")", "&&", "$", "this", "->", "_license", "->", "is_features...
Check if site assigned with license with enabled features. @author Vova Feldman (@svovaf) @since 1.0.6 @return bool
[ "Check", "if", "site", "assigned", "with", "license", "with", "enabled", "features", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L17063-L17069
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._sync_license
private function _sync_license( $background = false, $is_context_single_site = false, $current_blog_id = null ) { $this->_logger->entrance(); $plugin_id = fs_request_get( 'plugin_id', $this->get_id() ); $is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() ); if ( $is_addon_sync ) { $this->_sync_addon_license( $plugin_id, $background ); } else { $this->_sync_plugin_license( $background, true, $is_context_single_site, $current_blog_id ); } $this->do_action( 'after_account_plan_sync', $this->get_plan_name() ); }
php
private function _sync_license( $background = false, $is_context_single_site = false, $current_blog_id = null ) { $this->_logger->entrance(); $plugin_id = fs_request_get( 'plugin_id', $this->get_id() ); $is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() ); if ( $is_addon_sync ) { $this->_sync_addon_license( $plugin_id, $background ); } else { $this->_sync_plugin_license( $background, true, $is_context_single_site, $current_blog_id ); } $this->do_action( 'after_account_plan_sync', $this->get_plan_name() ); }
[ "private", "function", "_sync_license", "(", "$", "background", "=", "false", ",", "$", "is_context_single_site", "=", "false", ",", "$", "current_blog_id", "=", "null", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "plugin_...
Sync site's plan. @author Vova Feldman (@svovaf) @since 1.0.3 @uses FS_Api @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by the admin. @param bool $is_context_single_site @since 2.0.0. This is used when syncing a license for a single install from the network-level "Account" page. @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.
[ "Sync", "site", "s", "plan", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L17127-L17141
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._sync_addon_license
private function _sync_addon_license( $addon_id, $background ) { $this->_logger->entrance(); if ( $this->is_addon_activated( $addon_id ) ) { // If already installed, use add-on sync. $fs_addon = self::get_instance_by_id( $addon_id ); $fs_addon->_sync_license( $background ); return; } // Validate add-on exists. $addon = $this->get_addon( $addon_id ); if ( ! is_object( $addon ) ) { return; } // Add add-on into account add-ons. $account_addons = $this->get_account_addons(); if ( ! is_array( $account_addons ) ) { $account_addons = array(); } $account_addons[] = $addon->id; $account_addons = array_unique( $account_addons ); $this->_store_account_addons( $account_addons ); // Load add-on licenses. $licenses = $this->_fetch_licenses( $addon->id ); // Sync add-on licenses. if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) { $this->_update_licenses( $licenses, $addon->id ); if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) { $plans_result = $this->get_api_site_or_plugin_scope()->get( $this->add_show_pending( "/addons/{$addon_id}/plans.json" ) ); if ( ! isset( $plans_result->error ) ) { $plans = array(); foreach ( $plans_result->plans as $plan ) { $plans[] = new FS_Plugin_Plan( $plan ); } $this->_admin_notices->add_sticky( sprintf( ( FS_Plan_Manager::instance()->has_free_plan( $plans ) ? $this->get_text_inline( 'Your %s Add-on plan was successfully upgraded.', 'addon-successfully-upgraded-message' ) : /* translators: %s:product name, e.g. Facebook add-on was successfully... */ $this->get_text_inline( '%s Add-on was successfully purchased.', 'addon-successfully-purchased-message' ) ), $addon->title ) . ' ' . $this->get_latest_download_link( $this->get_text_inline( 'Download the latest version', 'download-latest-version' ), $addon_id ), 'addon_plan_upgraded_' . $addon->slug, $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!' ); } } } }
php
private function _sync_addon_license( $addon_id, $background ) { $this->_logger->entrance(); if ( $this->is_addon_activated( $addon_id ) ) { // If already installed, use add-on sync. $fs_addon = self::get_instance_by_id( $addon_id ); $fs_addon->_sync_license( $background ); return; } // Validate add-on exists. $addon = $this->get_addon( $addon_id ); if ( ! is_object( $addon ) ) { return; } // Add add-on into account add-ons. $account_addons = $this->get_account_addons(); if ( ! is_array( $account_addons ) ) { $account_addons = array(); } $account_addons[] = $addon->id; $account_addons = array_unique( $account_addons ); $this->_store_account_addons( $account_addons ); // Load add-on licenses. $licenses = $this->_fetch_licenses( $addon->id ); // Sync add-on licenses. if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) { $this->_update_licenses( $licenses, $addon->id ); if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) { $plans_result = $this->get_api_site_or_plugin_scope()->get( $this->add_show_pending( "/addons/{$addon_id}/plans.json" ) ); if ( ! isset( $plans_result->error ) ) { $plans = array(); foreach ( $plans_result->plans as $plan ) { $plans[] = new FS_Plugin_Plan( $plan ); } $this->_admin_notices->add_sticky( sprintf( ( FS_Plan_Manager::instance()->has_free_plan( $plans ) ? $this->get_text_inline( 'Your %s Add-on plan was successfully upgraded.', 'addon-successfully-upgraded-message' ) : /* translators: %s:product name, e.g. Facebook add-on was successfully... */ $this->get_text_inline( '%s Add-on was successfully purchased.', 'addon-successfully-purchased-message' ) ), $addon->title ) . ' ' . $this->get_latest_download_link( $this->get_text_inline( 'Download the latest version', 'download-latest-version' ), $addon_id ), 'addon_plan_upgraded_' . $addon->slug, $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!' ); } } } }
[ "private", "function", "_sync_addon_license", "(", "$", "addon_id", ",", "$", "background", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "$", "this", "->", "is_addon_activated", "(", "$", "addon_id", ")", ")", "{", ...
Sync plugin's add-on license. @author Vova Feldman (@svovaf) @since 1.0.6 @uses FS_Api @param number $addon_id @param bool $background
[ "Sync", "plugin", "s", "add", "-", "on", "license", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L17153-L17213
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._downgrade_site
private function _downgrade_site() { $this->_logger->entrance(); $deactivate_license = fs_request_get_bool( 'deactivate_license' ); $api = $this->get_api_site_scope(); $site = $api->call( 'downgrade.json', 'put', array( 'deactivate_license' => $deactivate_license ) ); $plan_downgraded = false; $plan = false; if ( $this->is_api_result_entity( $site ) ) { $prev_plan_id = $this->_site->plan_id; // Update new site plan id. $this->_site->plan_id = $site->plan_id; $plan = $this->get_plan(); $subscription = $this->_sync_site_subscription( $this->_license ); // Plan downgraded if plan was changed or subscription was cancelled. $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) || ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() ); } else { // handle different error cases. $this->handle_license_deactivation_result( $site, $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...' ); } if ( ! $plan_downgraded ) { return (object) array( 'error' => (object) array( 'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your subscription cancellation. Please try again in few minutes.', 'subscription-cancellation-failure-message' ) ) ); } // Remove previous sticky message about upgrade (if exist). $this->_admin_notices->remove_sticky( 'plan_upgraded' ); $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Your subscription was successfully cancelled. Your %s plan license will expire in %s.', 'plan-x-downgraded-message' ), $plan->title, human_time_diff( time(), strtotime( $this->_license->expiration ) ) ) ); // Store site updates. $this->_store_site(); if ( $deactivate_license && ! FS_Plugin_License::is_valid_id( $site->license_id ) ) { if ( $this->_site->is_localhost() ) { $this->_license->activated_local = max( 0, $this->_license->activated_local - 1 ); } else { $this->_license->activated = max( 0, $this->_license->activated - 1 ); } // Handle successful license deactivation result. $this->handle_license_deactivation_result( $this->_license ); } return $site; }
php
private function _downgrade_site() { $this->_logger->entrance(); $deactivate_license = fs_request_get_bool( 'deactivate_license' ); $api = $this->get_api_site_scope(); $site = $api->call( 'downgrade.json', 'put', array( 'deactivate_license' => $deactivate_license ) ); $plan_downgraded = false; $plan = false; if ( $this->is_api_result_entity( $site ) ) { $prev_plan_id = $this->_site->plan_id; // Update new site plan id. $this->_site->plan_id = $site->plan_id; $plan = $this->get_plan(); $subscription = $this->_sync_site_subscription( $this->_license ); // Plan downgraded if plan was changed or subscription was cancelled. $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) || ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() ); } else { // handle different error cases. $this->handle_license_deactivation_result( $site, $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...' ); } if ( ! $plan_downgraded ) { return (object) array( 'error' => (object) array( 'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your subscription cancellation. Please try again in few minutes.', 'subscription-cancellation-failure-message' ) ) ); } // Remove previous sticky message about upgrade (if exist). $this->_admin_notices->remove_sticky( 'plan_upgraded' ); $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Your subscription was successfully cancelled. Your %s plan license will expire in %s.', 'plan-x-downgraded-message' ), $plan->title, human_time_diff( time(), strtotime( $this->_license->expiration ) ) ) ); // Store site updates. $this->_store_site(); if ( $deactivate_license && ! FS_Plugin_License::is_valid_id( $site->license_id ) ) { if ( $this->_site->is_localhost() ) { $this->_license->activated_local = max( 0, $this->_license->activated_local - 1 ); } else { $this->_license->activated = max( 0, $this->_license->activated - 1 ); } // Handle successful license deactivation result. $this->handle_license_deactivation_result( $this->_license ); } return $site; }
[ "private", "function", "_downgrade_site", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "deactivate_license", "=", "fs_request_get_bool", "(", "'deactivate_license'", ")", ";", "$", "api", "=", "$", "this", "->", "get_api...
Site plan downgrade. @author Vova Feldman (@svovaf) @since 1.0.4 @return object @uses FS_Api
[ "Site", "plan", "downgrade", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L17834-L17899
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius._cancel_trial
private function _cancel_trial() { $this->_logger->entrance(); if ( ! $this->is_trial() ) { return (object) array( 'error' => (object) array( 'message' => $this->get_text_inline( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'trial-cancel-no-trial-message' ) ) ); } $trial_plan = $this->get_trial_plan(); $api = $this->get_api_site_scope(); $site = $api->call( 'trials.json', 'delete' ); $trial_cancelled = false; if ( $this->is_api_result_entity( $site ) ) { $prev_trial_ends = $this->_site->trial_ends; if ( $this->is_paid_trial() ) { $this->_license->expiration = $site->trial_ends; $this->_license->is_cancelled = true; $this->_update_site_license( $this->_license ); $this->_store_licenses(); // Clear subscription reference. $this->_sync_site_subscription( null ); } // Update site info. $this->_site = new FS_Site( $site ); $trial_cancelled = ( $prev_trial_ends != $site->trial_ends ); } else { // @todo handle different error cases. } if ( ! $trial_cancelled ) { return (object) array( 'error' => (object) array( 'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'trial-cancel-failure-message' ) ) ); } // Remove previous sticky messages about upgrade or trial (if exist). $this->_admin_notices->remove_sticky( array( 'trial_started', 'trial_promotion', 'plan_upgraded', ) ); // Store site updates. $this->_store_site(); if ( ! $this->is_addon() || ! $this->deactivate_premium_only_addon_without_license( true ) ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Your %s free trial was successfully cancelled.', 'trial-cancel-message' ), $trial_plan->title ) ); } return $site; }
php
private function _cancel_trial() { $this->_logger->entrance(); if ( ! $this->is_trial() ) { return (object) array( 'error' => (object) array( 'message' => $this->get_text_inline( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'trial-cancel-no-trial-message' ) ) ); } $trial_plan = $this->get_trial_plan(); $api = $this->get_api_site_scope(); $site = $api->call( 'trials.json', 'delete' ); $trial_cancelled = false; if ( $this->is_api_result_entity( $site ) ) { $prev_trial_ends = $this->_site->trial_ends; if ( $this->is_paid_trial() ) { $this->_license->expiration = $site->trial_ends; $this->_license->is_cancelled = true; $this->_update_site_license( $this->_license ); $this->_store_licenses(); // Clear subscription reference. $this->_sync_site_subscription( null ); } // Update site info. $this->_site = new FS_Site( $site ); $trial_cancelled = ( $prev_trial_ends != $site->trial_ends ); } else { // @todo handle different error cases. } if ( ! $trial_cancelled ) { return (object) array( 'error' => (object) array( 'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'trial-cancel-failure-message' ) ) ); } // Remove previous sticky messages about upgrade or trial (if exist). $this->_admin_notices->remove_sticky( array( 'trial_started', 'trial_promotion', 'plan_upgraded', ) ); // Store site updates. $this->_store_site(); if ( ! $this->is_addon() || ! $this->deactivate_premium_only_addon_without_license( true ) ) { $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Your %s free trial was successfully cancelled.', 'trial-cancel-message' ), $trial_plan->title ) ); } return $site; }
[ "private", "function", "_cancel_trial", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "is_trial", "(", ")", ")", "{", "return", "(", "object", ")", "array", "(", "'error'", "=>", "(...
Cancel site trial. @author Vova Feldman (@svovaf) @since 1.0.9 @return object @uses FS_Api
[ "Cancel", "site", "trial", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L18009-L18075
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.update_email
private function update_email( $new_email ) { $this->_logger->entrance(); $api = $this->get_api_user_scope(); $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array( 'email' => $new_email, 'after_email_confirm_url' => $this->_get_admin_page_url( 'account', array( 'fs_action' => 'sync_user' ) ), ) ); if ( ! isset( $user->error ) ) { $this->_user->email = $user->email; $this->_user->is_verified = $user->is_verified; $this->_store_user(); } else { // handle different error cases. } return $user; }
php
private function update_email( $new_email ) { $this->_logger->entrance(); $api = $this->get_api_user_scope(); $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array( 'email' => $new_email, 'after_email_confirm_url' => $this->_get_admin_page_url( 'account', array( 'fs_action' => 'sync_user' ) ), ) ); if ( ! isset( $user->error ) ) { $this->_user->email = $user->email; $this->_user->is_verified = $user->is_verified; $this->_store_user(); } else { // handle different error cases. } return $user; }
[ "private", "function", "update_email", "(", "$", "new_email", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "api", "=", "$", "this", "->", "get_api_user_scope", "(", ")", ";", "$", "user", "=", "$", "api", "->", "call"...
Handle user email update. @author Vova Feldman (@svovaf) @since 1.0.3 @uses FS_Api @param string $new_email @return object
[ "Handle", "user", "email", "update", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L18458-L18481
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.init_change_owner
private function init_change_owner( $candidate_email ) { $this->_logger->entrance(); $api = $this->get_api_site_scope(); $result = $api->call( "/users/{$this->_user->id}.json", 'put', array( 'email' => $candidate_email, 'after_confirm_url' => $this->_get_admin_page_url( 'account', array( 'fs_action' => 'change_owner' ) ), ) ); return ! $this->is_api_error( $result ); }
php
private function init_change_owner( $candidate_email ) { $this->_logger->entrance(); $api = $this->get_api_site_scope(); $result = $api->call( "/users/{$this->_user->id}.json", 'put', array( 'email' => $candidate_email, 'after_confirm_url' => $this->_get_admin_page_url( 'account', array( 'fs_action' => 'change_owner' ) ), ) ); return ! $this->is_api_error( $result ); }
[ "private", "function", "init_change_owner", "(", "$", "candidate_email", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "api", "=", "$", "this", "->", "get_api_site_scope", "(", ")", ";", "$", "result", "=", "$", "api", "...
Start install ownership change. @author Vova Feldman (@svovaf) @since 1.1.1 @uses FS_Api @param string $candidate_email @return bool Is ownership change successfully initiated.
[ "Start", "install", "ownership", "change", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L18556-L18569
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.complete_change_owner
private function complete_change_owner() { $this->_logger->entrance(); $site_result = $this->get_api_site_scope( true )->get(); $site = new FS_Site( $site_result ); $this->_site = $site; $user = new FS_User(); $user->id = fs_request_get( 'user_id' ); // Validate install's user and given user. if ( $user->id != $this->_site->user_id ) { return false; } $user->public_key = fs_request_get( 'user_public_key' ); $user->secret_key = fs_request_get( 'user_secret_key' ); // Fetch new user information. $this->_user = $user; $user_result = $this->get_api_user_scope( true )->get(); $user = new FS_User( $user_result ); $this->_user = $user; $this->_set_account( $user, $site ); return true; }
php
private function complete_change_owner() { $this->_logger->entrance(); $site_result = $this->get_api_site_scope( true )->get(); $site = new FS_Site( $site_result ); $this->_site = $site; $user = new FS_User(); $user->id = fs_request_get( 'user_id' ); // Validate install's user and given user. if ( $user->id != $this->_site->user_id ) { return false; } $user->public_key = fs_request_get( 'user_public_key' ); $user->secret_key = fs_request_get( 'user_secret_key' ); // Fetch new user information. $this->_user = $user; $user_result = $this->get_api_user_scope( true )->get(); $user = new FS_User( $user_result ); $this->_user = $user; $this->_set_account( $user, $site ); return true; }
[ "private", "function", "complete_change_owner", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "site_result", "=", "$", "this", "->", "get_api_site_scope", "(", "true", ")", "->", "get", "(", ")", ";", "$", "site", "...
Handle install ownership change. @author Vova Feldman (@svovaf) @since 1.1.1 @uses FS_Api @return bool Was ownership change successfully complete.
[ "Handle", "install", "ownership", "change", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L18580-L18607
train
Freemius/wordpress-sdk
includes/class-freemius.php
Freemius.update_user_name
private function update_user_name() { $this->_logger->entrance(); $name = fs_request_get( 'fs_user_name_' . $this->get_unique_affix(), '' ); $api = $this->get_api_user_scope(); $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array( 'name' => $name, ) ); if ( ! isset( $user->error ) ) { $this->_user->first = $user->first; $this->_user->last = $user->last; $this->_store_user(); } else { // handle different error cases. } return $user; }
php
private function update_user_name() { $this->_logger->entrance(); $name = fs_request_get( 'fs_user_name_' . $this->get_unique_affix(), '' ); $api = $this->get_api_user_scope(); $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array( 'name' => $name, ) ); if ( ! isset( $user->error ) ) { $this->_user->first = $user->first; $this->_user->last = $user->last; $this->_store_user(); } else { // handle different error cases. } return $user; }
[ "private", "function", "update_user_name", "(", ")", "{", "$", "this", "->", "_logger", "->", "entrance", "(", ")", ";", "$", "name", "=", "fs_request_get", "(", "'fs_user_name_'", ".", "$", "this", "->", "get_unique_affix", "(", ")", ",", "''", ")", ";"...
Handle user name update. @author Vova Feldman (@svovaf) @since 1.0.9 @uses FS_Api @return object
[ "Handle", "user", "name", "update", "." ]
a4cc02a705639bcc64b5b55b8732432986b1b228
https://github.com/Freemius/wordpress-sdk/blob/a4cc02a705639bcc64b5b55b8732432986b1b228/includes/class-freemius.php#L18618-L18637
train