id
int32
0
241k
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
46,100
Codeinwp/themeisle-sdk
src/Modules/Recommendation.php
Recommendation.get_themes
private function get_themes( $themes_list, $preferences ) { $list = array(); foreach ( $themes_list as $slug => $nicename ) { $theme = $this->call_theme_api( $slug ); if ( ! $theme ) { continue; } $url = add_query_arg( array( 'theme' => $theme->slug, ), network_admin_url( 'theme-install.php' ) ); $name = empty( $nicename ) ? $theme->name : $nicename; $theme->custom_url = $url; $theme->custom_name = $name; $list[] = $theme; } return $list; }
php
private function get_themes( $themes_list, $preferences ) { $list = array(); foreach ( $themes_list as $slug => $nicename ) { $theme = $this->call_theme_api( $slug ); if ( ! $theme ) { continue; } $url = add_query_arg( array( 'theme' => $theme->slug, ), network_admin_url( 'theme-install.php' ) ); $name = empty( $nicename ) ? $theme->name : $nicename; $theme->custom_url = $url; $theme->custom_name = $name; $list[] = $theme; } return $list; }
[ "private", "function", "get_themes", "(", "$", "themes_list", ",", "$", "preferences", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "themes_list", "as", "$", "slug", "=>", "$", "nicename", ")", "{", "$", "theme", "=", "$",...
Collect all the information for the themes list. @param array $themes_list - list of useful themes (in slug => nicename format). @param array $preferences - list of preferences. @return array
[ "Collect", "all", "the", "information", "for", "the", "themes", "list", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Recommendation.php#L148-L172
46,101
Codeinwp/themeisle-sdk
src/Modules/Recommendation.php
Recommendation.call_theme_api
private function call_theme_api( $slug ) { $theme = get_transient( 'ti_theme_info_' . $slug ); if ( false !== $theme ) { return $theme; } $products = wp_remote_get( 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[theme]=' . $slug . '&request[per_page]=1' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $theme = $products->themes[0]; set_transient( 'ti_theme_info_' . $slug, $theme, 6 * HOUR_IN_SECONDS ); } return $theme; }
php
private function call_theme_api( $slug ) { $theme = get_transient( 'ti_theme_info_' . $slug ); if ( false !== $theme ) { return $theme; } $products = wp_remote_get( 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[theme]=' . $slug . '&request[per_page]=1' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $theme = $products->themes[0]; set_transient( 'ti_theme_info_' . $slug, $theme, 6 * HOUR_IN_SECONDS ); } return $theme; }
[ "private", "function", "call_theme_api", "(", "$", "slug", ")", "{", "$", "theme", "=", "get_transient", "(", "'ti_theme_info_'", ".", "$", "slug", ")", ";", "if", "(", "false", "!==", "$", "theme", ")", "{", "return", "$", "theme", ";", "}", "$", "p...
Call theme api @param string $slug theme slug. @return array|mixed|object
[ "Call", "theme", "api" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Recommendation.php#L181-L198
46,102
Codeinwp/themeisle-sdk
src/Modules/Recommendation.php
Recommendation.get_plugins
private function get_plugins( $plugins_list, $preferences ) { $list = array(); foreach ( $plugins_list as $plugin => $nicename ) { $current_plugin = $this->call_plugin_api( $plugin ); $name = empty( $nicename ) ? $current_plugin->name : $nicename; $image = $current_plugin->banners['low']; if ( isset( $preferences['image'] ) && 'icon' === $preferences['image'] ) { $image = $current_plugin->icons['1x']; } $url = add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => $current_plugin->slug, 'TB_iframe' => true, 'width' => 800, 'height' => 800, ), network_admin_url( 'plugin-install.php' ) ); $current_plugin->custom_url = $url; $current_plugin->custom_name = $name; $current_plugin->custom_image = $image; $list[] = $current_plugin; } return $list; }
php
private function get_plugins( $plugins_list, $preferences ) { $list = array(); foreach ( $plugins_list as $plugin => $nicename ) { $current_plugin = $this->call_plugin_api( $plugin ); $name = empty( $nicename ) ? $current_plugin->name : $nicename; $image = $current_plugin->banners['low']; if ( isset( $preferences['image'] ) && 'icon' === $preferences['image'] ) { $image = $current_plugin->icons['1x']; } $url = add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => $current_plugin->slug, 'TB_iframe' => true, 'width' => 800, 'height' => 800, ), network_admin_url( 'plugin-install.php' ) ); $current_plugin->custom_url = $url; $current_plugin->custom_name = $name; $current_plugin->custom_image = $image; $list[] = $current_plugin; } return $list; }
[ "private", "function", "get_plugins", "(", "$", "plugins_list", ",", "$", "preferences", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "plugins_list", "as", "$", "plugin", "=>", "$", "nicename", ")", "{", "$", "current_plugin",...
Collect all the information for the plugins list. @param array $plugins_list - list of useful plugins (in slug => nicename format). @param array $preferences - list of preferences. @return array
[ "Collect", "all", "the", "information", "for", "the", "plugins", "list", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Recommendation.php#L208-L239
46,103
Codeinwp/themeisle-sdk
src/Modules/Recommendation.php
Recommendation.call_plugin_api
private function call_plugin_api( $slug ) { include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); $call_api = get_transient( 'ti_plugin_info_' . $slug ); if ( false === $call_api ) { $call_api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'downloaded' => false, 'rating' => false, 'description' => false, 'short_description' => true, 'donate_link' => false, 'tags' => false, 'sections' => true, 'homepage' => true, 'added' => false, 'last_updated' => false, 'compatibility' => false, 'tested' => false, 'requires' => false, 'downloadlink' => false, 'icons' => true, 'banners' => true, ), ) ); set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); } return $call_api; }
php
private function call_plugin_api( $slug ) { include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); $call_api = get_transient( 'ti_plugin_info_' . $slug ); if ( false === $call_api ) { $call_api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'downloaded' => false, 'rating' => false, 'description' => false, 'short_description' => true, 'donate_link' => false, 'tags' => false, 'sections' => true, 'homepage' => true, 'added' => false, 'last_updated' => false, 'compatibility' => false, 'tested' => false, 'requires' => false, 'downloadlink' => false, 'icons' => true, 'banners' => true, ), ) ); set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); } return $call_api; }
[ "private", "function", "call_plugin_api", "(", "$", "slug", ")", "{", "include_once", "(", "ABSPATH", ".", "'wp-admin/includes/plugin-install.php'", ")", ";", "$", "call_api", "=", "get_transient", "(", "'ti_plugin_info_'", ".", "$", "slug", ")", ";", "if", "(",...
Call plugin api @param string $slug plugin slug. @return array|mixed|object
[ "Call", "plugin", "api" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Recommendation.php#L248-L282
46,104
Codeinwp/themeisle-sdk
src/Modules/Recommendation.php
Recommendation.enqueue
public function enqueue() { $screen = get_current_screen(); if ( ! isset( $screen->id ) ) { return; } if ( false === apply_filters( $this->product->get_key() . '_enqueue_recommend', false, $screen->id ) ) { return; } ?> <style type="text/css"> .recommend-product { display: flex; justify-content: space-between; flex-wrap: wrap; } .recommend-product .theme-banner { width:200px; margin: auto; } .recommend-product .plugin-banner { width: 100px; margin: auto; } .recommend-product .plugin_box .button span{ margin-top: 2px; margin-right: 7px; } .recommend-product .plugin_box .button{ margin-bottom:10px; } .recommend-product .plugin_box { margin-bottom: 20px; padding-top: 5px; display: flex; box-shadow: 0px 0px 10px -5px rgba(0,0,0,0.55); background: #fff; border-radius: 5px; flex-direction: column; justify-content: flex-start; width: 95%; } .recommend-product .title-action-wrapper { padding: 15px 20px 5px 20px; } .recommend-product .plugin-name { font-size: 18px; display: block; white-space: nowrap; text-overflow: ellipsis; margin-bottom: 10px; overflow: hidden; line-height: normal; } .recommend-product .plugin-desc { display: block; margin-bottom: 10px; font-size: 13px; color: #777; line-height: 1.6; } .recommend-product .button-wrap > div { padding: 0; margin: 0; } .plugin-box-footer { display: flex; justify-content: space-around; vertical-align: middle; align-items: center; padding: 0px 10px 5px; flex: 1; margin-top: auto; } </style> <?php }
php
public function enqueue() { $screen = get_current_screen(); if ( ! isset( $screen->id ) ) { return; } if ( false === apply_filters( $this->product->get_key() . '_enqueue_recommend', false, $screen->id ) ) { return; } ?> <style type="text/css"> .recommend-product { display: flex; justify-content: space-between; flex-wrap: wrap; } .recommend-product .theme-banner { width:200px; margin: auto; } .recommend-product .plugin-banner { width: 100px; margin: auto; } .recommend-product .plugin_box .button span{ margin-top: 2px; margin-right: 7px; } .recommend-product .plugin_box .button{ margin-bottom:10px; } .recommend-product .plugin_box { margin-bottom: 20px; padding-top: 5px; display: flex; box-shadow: 0px 0px 10px -5px rgba(0,0,0,0.55); background: #fff; border-radius: 5px; flex-direction: column; justify-content: flex-start; width: 95%; } .recommend-product .title-action-wrapper { padding: 15px 20px 5px 20px; } .recommend-product .plugin-name { font-size: 18px; display: block; white-space: nowrap; text-overflow: ellipsis; margin-bottom: 10px; overflow: hidden; line-height: normal; } .recommend-product .plugin-desc { display: block; margin-bottom: 10px; font-size: 13px; color: #777; line-height: 1.6; } .recommend-product .button-wrap > div { padding: 0; margin: 0; } .plugin-box-footer { display: flex; justify-content: space-around; vertical-align: middle; align-items: center; padding: 0px 10px 5px; flex: 1; margin-top: auto; } </style> <?php }
[ "public", "function", "enqueue", "(", ")", "{", "$", "screen", "=", "get_current_screen", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "screen", "->", "id", ")", ")", "{", "return", ";", "}", "if", "(", "false", "===", "apply_filters", "(", "$...
Load css and scripts for the plugin recommend page.
[ "Load", "css", "and", "scripts", "for", "the", "plugin", "recommend", "page", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Recommendation.php#L287-L373
46,105
Codeinwp/themeisle-sdk
src/Product.php
Product.setup_from_path
public function setup_from_path() { $this->file = basename( $this->basefile ); $dir = dirname( $this->basefile ); $this->slug = basename( $dir ); $exts = explode( '.', $this->basefile ); $ext = $exts[ count( $exts ) - 1 ]; if ( 'css' === $ext ) { $this->type = 'theme'; } if ( 'php' === $ext ) { $this->type = 'plugin'; } $this->key = self::key_ready_name( $this->slug ); }
php
public function setup_from_path() { $this->file = basename( $this->basefile ); $dir = dirname( $this->basefile ); $this->slug = basename( $dir ); $exts = explode( '.', $this->basefile ); $ext = $exts[ count( $exts ) - 1 ]; if ( 'css' === $ext ) { $this->type = 'theme'; } if ( 'php' === $ext ) { $this->type = 'plugin'; } $this->key = self::key_ready_name( $this->slug ); }
[ "public", "function", "setup_from_path", "(", ")", "{", "$", "this", "->", "file", "=", "basename", "(", "$", "this", "->", "basefile", ")", ";", "$", "dir", "=", "dirname", "(", "$", "this", "->", "basefile", ")", ";", "$", "this", "->", "slug", "...
Setup props from path.
[ "Setup", "props", "from", "path", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Product.php#L135-L148
46,106
Codeinwp/themeisle-sdk
src/Product.php
Product.setup_from_fileheaders
public function setup_from_fileheaders() { $file_headers = array( 'Requires License' => 'Requires License', 'WordPress Available' => 'WordPress Available', 'Pro Slug' => 'Pro Slug', 'Version' => 'Version', ); if ( 'plugin' === $this->type ) { $file_headers['Name'] = 'Plugin Name'; $file_headers['AuthorName'] = 'Author'; $file_headers['AuthorURI'] = 'Author URI'; } if ( 'theme' === $this->type ) { $file_headers['Name'] = 'Theme Name'; $file_headers['AuthorName'] = 'Author'; $file_headers['AuthorURI'] = 'Author URI'; } $file_headers = get_file_data( $this->basefile, $file_headers ); $this->name = $file_headers['Name']; $this->store_name = $file_headers['AuthorName']; $this->author_url = $file_headers['AuthorURI']; $this->store_url = $file_headers['AuthorURI']; $this->requires_license = ( 'yes' === $file_headers['Requires License'] ) ? true : false; $this->wordpress_available = ( 'yes' === $file_headers['WordPress Available'] ) ? true : false; $this->pro_slug = ! empty( $file_headers['Pro Slug'] ) ? $file_headers['Pro Slug'] : ''; $this->version = $file_headers['Version']; }
php
public function setup_from_fileheaders() { $file_headers = array( 'Requires License' => 'Requires License', 'WordPress Available' => 'WordPress Available', 'Pro Slug' => 'Pro Slug', 'Version' => 'Version', ); if ( 'plugin' === $this->type ) { $file_headers['Name'] = 'Plugin Name'; $file_headers['AuthorName'] = 'Author'; $file_headers['AuthorURI'] = 'Author URI'; } if ( 'theme' === $this->type ) { $file_headers['Name'] = 'Theme Name'; $file_headers['AuthorName'] = 'Author'; $file_headers['AuthorURI'] = 'Author URI'; } $file_headers = get_file_data( $this->basefile, $file_headers ); $this->name = $file_headers['Name']; $this->store_name = $file_headers['AuthorName']; $this->author_url = $file_headers['AuthorURI']; $this->store_url = $file_headers['AuthorURI']; $this->requires_license = ( 'yes' === $file_headers['Requires License'] ) ? true : false; $this->wordpress_available = ( 'yes' === $file_headers['WordPress Available'] ) ? true : false; $this->pro_slug = ! empty( $file_headers['Pro Slug'] ) ? $file_headers['Pro Slug'] : ''; $this->version = $file_headers['Version']; }
[ "public", "function", "setup_from_fileheaders", "(", ")", "{", "$", "file_headers", "=", "array", "(", "'Requires License'", "=>", "'Requires License'", ",", "'WordPress Available'", "=>", "'WordPress Available'", ",", "'Pro Slug'", "=>", "'Pro Slug'", ",", "'Version'",...
Setup props from fileheaders.
[ "Setup", "props", "from", "fileheaders", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Product.php#L164-L193
46,107
Codeinwp/themeisle-sdk
src/Product.php
Product.get_license
public function get_license() { if ( ! $this->requires_license() && ! $this->is_wordpress_available() ) { return 'free'; } $license_data = get_option( $this->get_key() . '_license_data', '' ); if ( empty( $license_data ) ) { return get_option( $this->get_key() . '_license', '' ); } if ( ! isset( $license_data->key ) ) { return get_option( $this->get_key() . '_license', '' ); } return $license_data->key; }
php
public function get_license() { if ( ! $this->requires_license() && ! $this->is_wordpress_available() ) { return 'free'; } $license_data = get_option( $this->get_key() . '_license_data', '' ); if ( empty( $license_data ) ) { return get_option( $this->get_key() . '_license', '' ); } if ( ! isset( $license_data->key ) ) { return get_option( $this->get_key() . '_license', '' ); } return $license_data->key; }
[ "public", "function", "get_license", "(", ")", "{", "if", "(", "!", "$", "this", "->", "requires_license", "(", ")", "&&", "!", "$", "this", "->", "is_wordpress_available", "(", ")", ")", "{", "return", "'free'", ";", "}", "$", "license_data", "=", "ge...
Returns current product license, if available. @return string Return license key, if available.
[ "Returns", "current", "product", "license", "if", "available", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Product.php#L274-L289
46,108
Codeinwp/themeisle-sdk
src/Product.php
Product.get_friendly_name
public function get_friendly_name() { $name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) ); $name = rtrim( $name, '- ()' ); return $name; }
php
public function get_friendly_name() { $name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) ); $name = rtrim( $name, '- ()' ); return $name; }
[ "public", "function", "get_friendly_name", "(", ")", "{", "$", "name", "=", "apply_filters", "(", "$", "this", "->", "get_key", "(", ")", ".", "'_friendly_name'", ",", "trim", "(", "str_replace", "(", "'Lite'", ",", "''", ",", "$", "this", "->", "get_nam...
Return friendly name. @return string Friendly name.
[ "Return", "friendly", "name", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Product.php#L314-L319
46,109
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.add_footer
public function add_footer() { $screen = get_current_screen(); if ( ! isset( $screen->parent_file ) ) { return; } if ( 'themes.php' !== $screen->parent_file ) { return; } if ( ! $this->product->is_theme() ) { return; } $version = $this->get_rollback(); if ( empty( $version ) ) { return; } ?> <script type="text/javascript"> jQuery(document).ready(function ($) { setInterval(checkTheme, 500); function checkTheme() { var theme = '<?php echo esc_attr( $this->product->get_slug() ); ?>-action'; if (jQuery('#' + theme).length > 0) { if (jQuery('.theme-overlay.active').is(':visible')) { if (jQuery('#' + theme + '-rollback').length === 0) { jQuery('.theme-actions .active-theme').prepend('<a class="button" style="float:left" id="' + theme + '-rollback" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) ); ?>">Rollback to v<?php echo esc_attr( $version['version'] ); ?></a>') } } } } }) </script> <?php }
php
public function add_footer() { $screen = get_current_screen(); if ( ! isset( $screen->parent_file ) ) { return; } if ( 'themes.php' !== $screen->parent_file ) { return; } if ( ! $this->product->is_theme() ) { return; } $version = $this->get_rollback(); if ( empty( $version ) ) { return; } ?> <script type="text/javascript"> jQuery(document).ready(function ($) { setInterval(checkTheme, 500); function checkTheme() { var theme = '<?php echo esc_attr( $this->product->get_slug() ); ?>-action'; if (jQuery('#' + theme).length > 0) { if (jQuery('.theme-overlay.active').is(':visible')) { if (jQuery('#' + theme + '-rollback').length === 0) { jQuery('.theme-actions .active-theme').prepend('<a class="button" style="float:left" id="' + theme + '-rollback" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) ); ?>">Rollback to v<?php echo esc_attr( $version['version'] ); ?></a>') } } } } }) </script> <?php }
[ "public", "function", "add_footer", "(", ")", "{", "$", "screen", "=", "get_current_screen", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "screen", "->", "parent_file", ")", ")", "{", "return", ";", "}", "if", "(", "'themes.php'", "!==", "$", "s...
Add js scripts for themes rollback.
[ "Add", "js", "scripts", "for", "themes", "rollback", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L30-L67
46,110
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.get_rollback
public function get_rollback() { $rollback = array(); $versions = $this->get_api_versions(); $versions = apply_filters( $this->product->get_key() . '_rollbacks', $versions ); if ( empty( $versions ) ) { return $rollback; } if ( $versions ) { usort( $versions, array( $this, 'sort_rollback_array' ) ); foreach ( $versions as $version ) { if ( isset( $version['version'] ) && isset( $version['url'] ) && version_compare( $this->product->get_version(), $version['version'], '>' ) ) { $rollback = $version; break; } } } return $rollback; }
php
public function get_rollback() { $rollback = array(); $versions = $this->get_api_versions(); $versions = apply_filters( $this->product->get_key() . '_rollbacks', $versions ); if ( empty( $versions ) ) { return $rollback; } if ( $versions ) { usort( $versions, array( $this, 'sort_rollback_array' ) ); foreach ( $versions as $version ) { if ( isset( $version['version'] ) && isset( $version['url'] ) && version_compare( $this->product->get_version(), $version['version'], '>' ) ) { $rollback = $version; break; } } } return $rollback; }
[ "public", "function", "get_rollback", "(", ")", "{", "$", "rollback", "=", "array", "(", ")", ";", "$", "versions", "=", "$", "this", "->", "get_api_versions", "(", ")", ";", "$", "versions", "=", "apply_filters", "(", "$", "this", "->", "product", "->...
Get the last rollback for this product. @return array The rollback version.
[ "Get", "the", "last", "rollback", "for", "this", "product", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L74-L92
46,111
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.get_api_versions
private function get_api_versions() { $cache_key = $this->product->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->product->get_version() ) . 'versions'; $cache_versions = get_transient( $cache_key ); if ( false === $cache_versions ) { $versions = $this->get_remote_versions(); set_transient( $cache_key, $versions, 5 * DAY_IN_SECONDS ); } else { $versions = is_array( $cache_versions ) ? $cache_versions : array(); } return $versions; }
php
private function get_api_versions() { $cache_key = $this->product->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->product->get_version() ) . 'versions'; $cache_versions = get_transient( $cache_key ); if ( false === $cache_versions ) { $versions = $this->get_remote_versions(); set_transient( $cache_key, $versions, 5 * DAY_IN_SECONDS ); } else { $versions = is_array( $cache_versions ) ? $cache_versions : array(); } return $versions; }
[ "private", "function", "get_api_versions", "(", ")", "{", "$", "cache_key", "=", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_'", ".", "preg_replace", "(", "'/[^0-9a-zA-Z ]/m'", ",", "''", ",", "$", "this", "->", "product", "->", "get...
Get versions array from wp.org @return array Array of versions.
[ "Get", "versions", "array", "from", "wp", ".", "org" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L99-L111
46,112
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.get_remote_versions
private function get_remote_versions() { $url = $this->get_versions_api_url(); if ( empty( $url ) ) { return []; } $response = wp_remote_get( $url ); if ( is_wp_error( $response ) ) { return array(); } $response = wp_remote_retrieve_body( $response ); if ( is_serialized( $response ) ) { $response = maybe_unserialize( $response ); } else { $response = json_decode( $response ); } if ( ! is_object( $response ) ) { return array(); } if ( ! isset( $response->versions ) ) { return array(); } $versions = array(); foreach ( $response->versions as $key => $value ) { $versions[] = array( 'version' => is_object( $value ) ? $value->version : $key, 'url' => is_object( $value ) ? $value->file : $value, ); } return $versions; }
php
private function get_remote_versions() { $url = $this->get_versions_api_url(); if ( empty( $url ) ) { return []; } $response = wp_remote_get( $url ); if ( is_wp_error( $response ) ) { return array(); } $response = wp_remote_retrieve_body( $response ); if ( is_serialized( $response ) ) { $response = maybe_unserialize( $response ); } else { $response = json_decode( $response ); } if ( ! is_object( $response ) ) { return array(); } if ( ! isset( $response->versions ) ) { return array(); } $versions = array(); foreach ( $response->versions as $key => $value ) { $versions[] = array( 'version' => is_object( $value ) ? $value->version : $key, 'url' => is_object( $value ) ? $value->file : $value, ); } return $versions; }
[ "private", "function", "get_remote_versions", "(", ")", "{", "$", "url", "=", "$", "this", "->", "get_versions_api_url", "(", ")", ";", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "[", "]", ";", "}", "$", "response", "=", "wp_remote...
Get remote versions zips. @return array Array of available versions.
[ "Get", "remote", "versions", "zips", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L118-L151
46,113
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.get_versions_api_url
private function get_versions_api_url() { if ( $this->product->is_wordpress_available() && $this->product->is_plugin() ) { return sprintf( 'https://api.wordpress.org/plugins/info/1.0/%s', $this->product->get_slug() ); } if ( $this->product->is_wordpress_available() && $this->product->is_theme() ) { return sprintf( 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=%s&request[fields][versions]=true', $this->product->get_slug() ); } $license = $this->product->get_license(); if ( $this->product->requires_license() && strlen( $license ) < 10 ) { return ''; } return sprintf( '%s?edd_action=get_versions&name=%s&url=%s&license=%s', $this->product->get_store_url(), urlencode( $this->product->get_name() ), urlencode( get_site_url() ), $license ); }
php
private function get_versions_api_url() { if ( $this->product->is_wordpress_available() && $this->product->is_plugin() ) { return sprintf( 'https://api.wordpress.org/plugins/info/1.0/%s', $this->product->get_slug() ); } if ( $this->product->is_wordpress_available() && $this->product->is_theme() ) { return sprintf( 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=%s&request[fields][versions]=true', $this->product->get_slug() ); } $license = $this->product->get_license(); if ( $this->product->requires_license() && strlen( $license ) < 10 ) { return ''; } return sprintf( '%s?edd_action=get_versions&name=%s&url=%s&license=%s', $this->product->get_store_url(), urlencode( $this->product->get_name() ), urlencode( get_site_url() ), $license ); }
[ "private", "function", "get_versions_api_url", "(", ")", "{", "if", "(", "$", "this", "->", "product", "->", "is_wordpress_available", "(", ")", "&&", "$", "this", "->", "product", "->", "is_plugin", "(", ")", ")", "{", "return", "sprintf", "(", "'https://...
Return url where to check for versions. @return string Url where to check for versions.
[ "Return", "url", "where", "to", "check", "for", "versions", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L158-L171
46,114
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.add_rollback_link
public function add_rollback_link( $links ) { $version = $this->get_rollback(); if ( empty( $version ) ) { return $links; } $links[] = '<a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) . '">' . sprintf( apply_filters( $this->product->get_key() . '_rollback_label', 'Rollback to v%s' ), $version['version'] ) . '</a>'; return $links; }
php
public function add_rollback_link( $links ) { $version = $this->get_rollback(); if ( empty( $version ) ) { return $links; } $links[] = '<a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) . '">' . sprintf( apply_filters( $this->product->get_key() . '_rollback_label', 'Rollback to v%s' ), $version['version'] ) . '</a>'; return $links; }
[ "public", "function", "add_rollback_link", "(", "$", "links", ")", "{", "$", "version", "=", "$", "this", "->", "get_rollback", "(", ")", ";", "if", "(", "empty", "(", "$", "version", ")", ")", "{", "return", "$", "links", ";", "}", "$", "links", "...
Show the rollback links in the plugin page. @param array $links Plugin links. @return array $links Altered links.
[ "Show", "the", "rollback", "links", "in", "the", "plugin", "page", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L180-L188
46,115
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.start_rollback
public function start_rollback() { if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { wp_nonce_ays( '' ); } if ( $this->product->is_plugin() ) { $this->start_rollback_plugin(); return; } if ( $this->product->is_theme() ) { $this->start_rollback_theme(); return; } }
php
public function start_rollback() { if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { wp_nonce_ays( '' ); } if ( $this->product->is_plugin() ) { $this->start_rollback_plugin(); return; } if ( $this->product->is_theme() ) { $this->start_rollback_theme(); return; } }
[ "public", "function", "start_rollback", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "_GET", "[", "'_wpnonce'", "]", ")", "||", "!", "wp_verify_nonce", "(", "$", "_GET", "[", "'_wpnonce'", "]", ",", "$", "this", "->", "product", "->", "get_key", ...
Start the rollback operation.
[ "Start", "the", "rollback", "operation", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L193-L208
46,116
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.start_rollback_plugin
private function start_rollback_plugin() { $rollback = $this->get_rollback(); $plugin_transient = get_site_transient( 'update_plugins' ); $plugin_folder = $this->product->get_slug(); $plugin_file = $this->product->get_file(); $version = $rollback['version']; $temp_array = array( 'slug' => $plugin_folder, 'new_version' => $version, 'package' => $rollback['url'], ); $temp_object = (object) $temp_array; $plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object; set_site_transient( 'update_plugins', $plugin_transient ); $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); if ( false === $transient ) { set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); $plugin = $plugin_folder . '/' . $plugin_file; $nonce = 'upgrade-plugin_' . $plugin; $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); $upgrader_skin = new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ); $upgrader = new \Plugin_Upgrader( $upgrader_skin ); $upgrader->upgrade( $plugin ); delete_transient( $this->product->get_key() . '_warning_rollback' ); wp_die( '', $title, array( 'response' => 200, ) ); } }
php
private function start_rollback_plugin() { $rollback = $this->get_rollback(); $plugin_transient = get_site_transient( 'update_plugins' ); $plugin_folder = $this->product->get_slug(); $plugin_file = $this->product->get_file(); $version = $rollback['version']; $temp_array = array( 'slug' => $plugin_folder, 'new_version' => $version, 'package' => $rollback['url'], ); $temp_object = (object) $temp_array; $plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object; set_site_transient( 'update_plugins', $plugin_transient ); $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); if ( false === $transient ) { set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); $plugin = $plugin_folder . '/' . $plugin_file; $nonce = 'upgrade-plugin_' . $plugin; $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); $upgrader_skin = new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ); $upgrader = new \Plugin_Upgrader( $upgrader_skin ); $upgrader->upgrade( $plugin ); delete_transient( $this->product->get_key() . '_warning_rollback' ); wp_die( '', $title, array( 'response' => 200, ) ); } }
[ "private", "function", "start_rollback_plugin", "(", ")", "{", "$", "rollback", "=", "$", "this", "->", "get_rollback", "(", ")", ";", "$", "plugin_transient", "=", "get_site_transient", "(", "'update_plugins'", ")", ";", "$", "plugin_folder", "=", "$", "this"...
Start the rollback operation for the plugin.
[ "Start", "the", "rollback", "operation", "for", "the", "plugin", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L213-L250
46,117
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.start_rollback_theme
private function start_rollback_theme() { add_filter( 'update_theme_complete_actions', array( $this, 'alter_links_theme_upgrade' ) ); $rollback = $this->get_rollback(); $transient = get_site_transient( 'update_themes' ); $folder = $this->product->get_slug(); $version = $rollback['version']; $temp_array = array( 'new_version' => $version, 'package' => $rollback['url'], ); $transient->response[ $folder . '/style.css' ] = $temp_array; set_site_transient( 'update_themes', $transient ); $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); if ( false === $transient ) { set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); $theme = $folder . '/style.css'; $nonce = 'upgrade-theme_' . $theme; $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme ); $upgrader = new \Theme_Upgrader( new \Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) ); $upgrader->upgrade( $theme ); delete_transient( $this->product->get_key() . '_warning_rollback' ); wp_die( '', $title, array( 'response' => 200, ) ); } }
php
private function start_rollback_theme() { add_filter( 'update_theme_complete_actions', array( $this, 'alter_links_theme_upgrade' ) ); $rollback = $this->get_rollback(); $transient = get_site_transient( 'update_themes' ); $folder = $this->product->get_slug(); $version = $rollback['version']; $temp_array = array( 'new_version' => $version, 'package' => $rollback['url'], ); $transient->response[ $folder . '/style.css' ] = $temp_array; set_site_transient( 'update_themes', $transient ); $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); if ( false === $transient ) { set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); $theme = $folder . '/style.css'; $nonce = 'upgrade-theme_' . $theme; $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme ); $upgrader = new \Theme_Upgrader( new \Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) ); $upgrader->upgrade( $theme ); delete_transient( $this->product->get_key() . '_warning_rollback' ); wp_die( '', $title, array( 'response' => 200, ) ); } }
[ "private", "function", "start_rollback_theme", "(", ")", "{", "add_filter", "(", "'update_theme_complete_actions'", ",", "array", "(", "$", "this", ",", "'alter_links_theme_upgrade'", ")", ")", ";", "$", "rollback", "=", "$", "this", "->", "get_rollback", "(", "...
Start the rollback operation for the theme.
[ "Start", "the", "rollback", "operation", "for", "the", "theme", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L255-L290
46,118
Codeinwp/themeisle-sdk
src/Modules/Rollback.php
Rollback.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) { return false; } if ( $product->is_plugin() && ! current_user_can( 'install_plugins' ) ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) { return false; } if ( $product->is_plugin() && ! current_user_can( 'install_plugins' ) ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "product", "->", "is_theme", "(", ")", "&&", "!", "cu...
Loads product object. @param Product $product Product object. @return bool Should we load the module?
[ "Loads", "product", "object", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Rollback.php#L314-L327
46,119
Superbalist/php-pubsub-google-cloud
src/GoogleCloudPubSubAdapter.php
GoogleCloudPubSubAdapter.getTopicForChannel
protected function getTopicForChannel($channel) { $topic = $this->client->topic($channel); if ($this->autoCreateTopics && !$topic->exists()) { $topic->create(); } return $topic; }
php
protected function getTopicForChannel($channel) { $topic = $this->client->topic($channel); if ($this->autoCreateTopics && !$topic->exists()) { $topic->create(); } return $topic; }
[ "protected", "function", "getTopicForChannel", "(", "$", "channel", ")", "{", "$", "topic", "=", "$", "this", "->", "client", "->", "topic", "(", "$", "channel", ")", ";", "if", "(", "$", "this", "->", "autoCreateTopics", "&&", "!", "$", "topic", "->",...
Return a `Topic` instance from a channel name. If the topic doesn't exist, the topic is first created. @param string $channel @return \Google\Cloud\PubSub\Topic
[ "Return", "a", "Topic", "instance", "from", "a", "channel", "name", "." ]
d15d1f84d2fb1890efcd441b7831b0c0b422e3c1
https://github.com/Superbalist/php-pubsub-google-cloud/blob/d15d1f84d2fb1890efcd441b7831b0c0b422e3c1/src/GoogleCloudPubSubAdapter.php#L321-L328
46,120
Superbalist/php-pubsub-google-cloud
src/GoogleCloudPubSubAdapter.php
GoogleCloudPubSubAdapter.getSubscriptionForChannel
protected function getSubscriptionForChannel($channel) { $topic = $this->getTopicForChannel($channel); $clientIdentifier = $this->clientIdentifier ? $this->clientIdentifier : 'default'; $clientIdentifier .= '.' . $channel; $subscription = $topic->subscription($clientIdentifier); if ($this->autoCreateSubscriptions && !$subscription->exists()) { $subscription->create(); } return $subscription; }
php
protected function getSubscriptionForChannel($channel) { $topic = $this->getTopicForChannel($channel); $clientIdentifier = $this->clientIdentifier ? $this->clientIdentifier : 'default'; $clientIdentifier .= '.' . $channel; $subscription = $topic->subscription($clientIdentifier); if ($this->autoCreateSubscriptions && !$subscription->exists()) { $subscription->create(); } return $subscription; }
[ "protected", "function", "getSubscriptionForChannel", "(", "$", "channel", ")", "{", "$", "topic", "=", "$", "this", "->", "getTopicForChannel", "(", "$", "channel", ")", ";", "$", "clientIdentifier", "=", "$", "this", "->", "clientIdentifier", "?", "$", "th...
Return a `Subscription` instance from a channel name. If the subscription doesn't exist, the subscription is first created. @param string $channel @return \Google\Cloud\PubSub\Subscription
[ "Return", "a", "Subscription", "instance", "from", "a", "channel", "name", "." ]
d15d1f84d2fb1890efcd441b7831b0c0b422e3c1
https://github.com/Superbalist/php-pubsub-google-cloud/blob/d15d1f84d2fb1890efcd441b7831b0c0b422e3c1/src/GoogleCloudPubSubAdapter.php#L339-L349
46,121
Codeinwp/themeisle-sdk
src/Loader.php
Loader.init
public static function init() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) { self::$instance = new Loader(); $modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) ); foreach ( $modules as $key => $module ) { if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) { unset( $modules[ $key ] ); } } self::$available_modules = $modules; } }
php
public static function init() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) { self::$instance = new Loader(); $modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) ); foreach ( $modules as $key => $module ) { if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) { unset( $modules[ $key ] ); } } self::$available_modules = $modules; } }
[ "public", "static", "function", "init", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", "&&", "!", "(", "self", "::", "$", "instance", "instanceof", "Loader", ")", ")", "{", "self", "::", "$", "instance", "=", "new"...
Initialize the sdk logic.
[ "Initialize", "the", "sdk", "logic", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Loader.php#L65-L76
46,122
Codeinwp/themeisle-sdk
src/Loader.php
Loader.add_product
public static function add_product( $base_file ) { if ( ! is_readable( $base_file ) ) { return self::$instance; } $product = new Product( $base_file ); Module_Factory::attach( $product, self::get_modules() ); self::$products[ $product->get_slug() ] = $product; return self::$instance; }
php
public static function add_product( $base_file ) { if ( ! is_readable( $base_file ) ) { return self::$instance; } $product = new Product( $base_file ); Module_Factory::attach( $product, self::get_modules() ); self::$products[ $product->get_slug() ] = $product; return self::$instance; }
[ "public", "static", "function", "add_product", "(", "$", "base_file", ")", "{", "if", "(", "!", "is_readable", "(", "$", "base_file", ")", ")", "{", "return", "self", "::", "$", "instance", ";", "}", "$", "product", "=", "new", "Product", "(", "$", "...
Register product into SDK. @param string $base_file The product base file. @return Loader The singleton object.
[ "Register", "product", "into", "SDK", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Loader.php#L85-L97
46,123
Codeinwp/themeisle-sdk
src/Modules/Endpoint.php
Endpoint.checksum
function checksum( \WP_REST_Request $data ) { $products = Loader::get_products(); if ( self::PRODUCT_SPECIFIC ) { $params = $this->validate_params( $data, array( 'slug' ) ); foreach ( $products as $product ) { if ( $params['slug'] === $product->get_slug() ) { $products = array( $product ); break; } } } $response = array(); $custom_css = $this->has_custom_css(); if ( is_bool( $custom_css ) ) { $response['custom_css'] = $custom_css; } $response['child_theme'] = $this->get_theme_properties(); foreach ( $products as $product ) { $files = array(); switch ( $product->get_type() ) { case 'plugin': $files = array(); break; case 'theme': $files = array( 'style.css', 'functions.php' ); break; } $error = ''; // if any element in the $files array contains a '/', this would imply recursion is required. $diff = $this->generate_diff( $product, $files, array_reduce( $files, array( $this, 'is_recursion_required', ), false ) ); if ( is_wp_error( $diff ) ) { /** * Error returner by the diff checker method. * * @var \WP_Error $diff Error returned. */ $error = $diff->get_error_message(); $diff = array(); } $response['products'][] = array( 'slug' => $product->get_slug(), 'version' => $product->get_version(), 'diffs' => $diff, 'error' => $error, ); } return new \WP_REST_Response( array( 'checksum' => $response ) ); }
php
function checksum( \WP_REST_Request $data ) { $products = Loader::get_products(); if ( self::PRODUCT_SPECIFIC ) { $params = $this->validate_params( $data, array( 'slug' ) ); foreach ( $products as $product ) { if ( $params['slug'] === $product->get_slug() ) { $products = array( $product ); break; } } } $response = array(); $custom_css = $this->has_custom_css(); if ( is_bool( $custom_css ) ) { $response['custom_css'] = $custom_css; } $response['child_theme'] = $this->get_theme_properties(); foreach ( $products as $product ) { $files = array(); switch ( $product->get_type() ) { case 'plugin': $files = array(); break; case 'theme': $files = array( 'style.css', 'functions.php' ); break; } $error = ''; // if any element in the $files array contains a '/', this would imply recursion is required. $diff = $this->generate_diff( $product, $files, array_reduce( $files, array( $this, 'is_recursion_required', ), false ) ); if ( is_wp_error( $diff ) ) { /** * Error returner by the diff checker method. * * @var \WP_Error $diff Error returned. */ $error = $diff->get_error_message(); $diff = array(); } $response['products'][] = array( 'slug' => $product->get_slug(), 'version' => $product->get_version(), 'diffs' => $diff, 'error' => $error, ); } return new \WP_REST_Response( array( 'checksum' => $response ) ); }
[ "function", "checksum", "(", "\\", "WP_REST_Request", "$", "data", ")", "{", "$", "products", "=", "Loader", "::", "get_products", "(", ")", ";", "if", "(", "self", "::", "PRODUCT_SPECIFIC", ")", "{", "$", "params", "=", "$", "this", "->", "validate_para...
The checksum endpoint. @param \WP_REST_Request $data the request. @return \WP_REST_Response Response or the error
[ "The", "checksum", "endpoint", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Endpoint.php#L66-L130
46,124
Codeinwp/themeisle-sdk
src/Modules/Endpoint.php
Endpoint.validate_params
private function validate_params( \WP_REST_Request $data, $params ) { $collect = array(); foreach ( $params as $param ) { $value = sanitize_text_field( $data[ $param ] ); if ( empty( $value ) ) { return rest_ensure_response( new \WP_Error( 'themeisle_' . $param . '_invalid', sprintf( 'Invalid %', $param ), array( 'status' => 403, ) ) ); } else { $collect[ $param ] = $value; } } return $collect; }
php
private function validate_params( \WP_REST_Request $data, $params ) { $collect = array(); foreach ( $params as $param ) { $value = sanitize_text_field( $data[ $param ] ); if ( empty( $value ) ) { return rest_ensure_response( new \WP_Error( 'themeisle_' . $param . '_invalid', sprintf( 'Invalid %', $param ), array( 'status' => 403, ) ) ); } else { $collect[ $param ] = $value; } } return $collect; }
[ "private", "function", "validate_params", "(", "\\", "WP_REST_Request", "$", "data", ",", "$", "params", ")", "{", "$", "collect", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "value", "=", "sanitize_te...
Validates the parameters to the API @param \WP_REST_Request $data the request. @param array $params the parameters to validate. @return array of parameter name=>value
[ "Validates", "the", "parameters", "to", "the", "API" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Endpoint.php#L140-L160
46,125
Codeinwp/themeisle-sdk
src/Modules/Endpoint.php
Endpoint.has_custom_css
private function has_custom_css() { $query = new \WP_Query( array( 'post_type' => 'custom_css', 'post_status' => 'publish', 'numberposts' => 1, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) ); if ( $query->have_posts() ) { $query->the_post(); $content = get_the_content(); // if the content contains a colon, a CSS rule has been added. return strpos( $content, ':' ) === false ? false : true; } return false; }
php
private function has_custom_css() { $query = new \WP_Query( array( 'post_type' => 'custom_css', 'post_status' => 'publish', 'numberposts' => 1, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) ); if ( $query->have_posts() ) { $query->the_post(); $content = get_the_content(); // if the content contains a colon, a CSS rule has been added. return strpos( $content, ':' ) === false ? false : true; } return false; }
[ "private", "function", "has_custom_css", "(", ")", "{", "$", "query", "=", "new", "\\", "WP_Query", "(", "array", "(", "'post_type'", "=>", "'custom_css'", ",", "'post_status'", "=>", "'publish'", ",", "'numberposts'", "=>", "1", ",", "'update_post_meta_cache'",...
Check if custom css has been added to the theme. @return bool Whether custom css has been added to the theme.
[ "Check", "if", "custom", "css", "has", "been", "added", "to", "the", "theme", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Endpoint.php#L167-L187
46,126
Codeinwp/themeisle-sdk
src/Modules/Endpoint.php
Endpoint.get_theme_properties
function get_theme_properties() { if ( ! is_child_theme() ) { return false; } $properties = array(); $theme = wp_get_theme(); // @codingStandardsIgnoreStart $properties['name'] = $theme->Name; // @codingStandardsIgnoreEnd // get the files in the child theme. require_once( ABSPATH . 'wp-admin/includes/file.php' ); WP_Filesystem(); global $wp_filesystem; $path = str_replace( ABSPATH, $wp_filesystem->abspath(), get_stylesheet_directory() ); $list = $wp_filesystem->dirlist( $path, false, false ); if ( $list ) { $list = array_keys( self::flatten_dirlist( $list ) ); $properties['files'] = $list; } return $properties; }
php
function get_theme_properties() { if ( ! is_child_theme() ) { return false; } $properties = array(); $theme = wp_get_theme(); // @codingStandardsIgnoreStart $properties['name'] = $theme->Name; // @codingStandardsIgnoreEnd // get the files in the child theme. require_once( ABSPATH . 'wp-admin/includes/file.php' ); WP_Filesystem(); global $wp_filesystem; $path = str_replace( ABSPATH, $wp_filesystem->abspath(), get_stylesheet_directory() ); $list = $wp_filesystem->dirlist( $path, false, false ); if ( $list ) { $list = array_keys( self::flatten_dirlist( $list ) ); $properties['files'] = $list; } return $properties; }
[ "function", "get_theme_properties", "(", ")", "{", "if", "(", "!", "is_child_theme", "(", ")", ")", "{", "return", "false", ";", "}", "$", "properties", "=", "array", "(", ")", ";", "$", "theme", "=", "wp_get_theme", "(", ")", ";", "// @codingStandardsIg...
Get the current theme properties. @return mixed Properties of the current theme.
[ "Get", "the", "current", "theme", "properties", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Endpoint.php#L194-L217
46,127
Codeinwp/themeisle-sdk
src/Modules/Endpoint.php
Endpoint.generate_diff
private function generate_diff( $product, $files, $recurse = false ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); WP_Filesystem(); global $wp_filesystem; $diff = array(); $path = str_replace( ABSPATH, $wp_filesystem->abspath(), plugin_dir_path( $product->get_basefile() ) ); $list = $wp_filesystem->dirlist( $path, false, $recurse ); // nothing found. if ( ! $list ) { return $diff; } $list = array_keys( self::flatten_dirlist( $list ) ); // now let's get the valid files that actually exist. if ( empty( $files ) ) { $files = $list; } else { $files = array_intersect( $files, $list ); } // fetch the calculated hashes. if ( ! $wp_filesystem->is_readable( $path . '/' . self::HASH_FILE ) ) { return new WP_Error( 'themeisle_sdk_hash_not_found', sprintf( '%s not found', self::HASH_FILE ) ); } $hashes = json_decode( $wp_filesystem->get_contents( $path . '/' . self::HASH_FILE ), true ); ksort( $hashes ); $diff = array(); foreach ( $files as $file ) { // file does not exist in the hashes. if ( ! array_key_exists( $file, $hashes ) ) { continue; } $new = md5( $wp_filesystem->get_contents( $path . $file ) ); $old = $hashes[ $file ]; // same hash, bail. if ( $new === $old ) { continue; } $diff[] = $file; } return $diff; }
php
private function generate_diff( $product, $files, $recurse = false ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); WP_Filesystem(); global $wp_filesystem; $diff = array(); $path = str_replace( ABSPATH, $wp_filesystem->abspath(), plugin_dir_path( $product->get_basefile() ) ); $list = $wp_filesystem->dirlist( $path, false, $recurse ); // nothing found. if ( ! $list ) { return $diff; } $list = array_keys( self::flatten_dirlist( $list ) ); // now let's get the valid files that actually exist. if ( empty( $files ) ) { $files = $list; } else { $files = array_intersect( $files, $list ); } // fetch the calculated hashes. if ( ! $wp_filesystem->is_readable( $path . '/' . self::HASH_FILE ) ) { return new WP_Error( 'themeisle_sdk_hash_not_found', sprintf( '%s not found', self::HASH_FILE ) ); } $hashes = json_decode( $wp_filesystem->get_contents( $path . '/' . self::HASH_FILE ), true ); ksort( $hashes ); $diff = array(); foreach ( $files as $file ) { // file does not exist in the hashes. if ( ! array_key_exists( $file, $hashes ) ) { continue; } $new = md5( $wp_filesystem->get_contents( $path . $file ) ); $old = $hashes[ $file ]; // same hash, bail. if ( $new === $old ) { continue; } $diff[] = $file; } return $diff; }
[ "private", "function", "generate_diff", "(", "$", "product", ",", "$", "files", ",", "$", "recurse", "=", "false", ")", "{", "require_once", "(", "ABSPATH", ".", "'wp-admin/includes/file.php'", ")", ";", "WP_Filesystem", "(", ")", ";", "global", "$", "wp_fil...
Generate the diff of the files. @param Product $product Themeisle Product. @param array $files Array of files. @param bool $recurse Whether to recurse or not. @return mixed Diff data.
[ "Generate", "the", "diff", "of", "the", "files", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Endpoint.php#L253-L299
46,128
Codeinwp/themeisle-sdk
src/Common/Abstract_module.php
Abstract_Module.is_from_partner
public function is_from_partner( $product ) { foreach ( Module_Factory::$domains as $partner_domain ) { if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) { return true; } } return array_key_exists( $product->get_slug(), Module_Factory::$slugs ); }
php
public function is_from_partner( $product ) { foreach ( Module_Factory::$domains as $partner_domain ) { if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) { return true; } } return array_key_exists( $product->get_slug(), Module_Factory::$slugs ); }
[ "public", "function", "is_from_partner", "(", "$", "product", ")", "{", "foreach", "(", "Module_Factory", "::", "$", "domains", "as", "$", "partner_domain", ")", "{", "if", "(", "strpos", "(", "$", "product", "->", "get_store_url", "(", ")", ",", "$", "p...
Check if the product is from partner. @param Product $product Product data. @return bool Is product from partner.
[ "Check", "if", "the", "product", "is", "from", "partner", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Common/Abstract_module.php#L56-L65
46,129
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.disable_wporg_update
function disable_wporg_update( $r, $url ) { if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/' ) ) { return $r; } // Decode the JSON response. $themes = json_decode( $r['body']['themes'] ); unset( $themes->themes->{$this->product->get_slug()} ); // Encode the updated JSON response. $r['body']['themes'] = json_encode( $themes ); return $r; }
php
function disable_wporg_update( $r, $url ) { if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/' ) ) { return $r; } // Decode the JSON response. $themes = json_decode( $r['body']['themes'] ); unset( $themes->themes->{$this->product->get_slug()} ); // Encode the updated JSON response. $r['body']['themes'] = json_encode( $themes ); return $r; }
[ "function", "disable_wporg_update", "(", "$", "r", ",", "$", "url", ")", "{", "if", "(", "0", "!==", "strpos", "(", "$", "url", ",", "'https://api.wordpress.org/themes/update-check/'", ")", ")", "{", "return", "$", "r", ";", "}", "// Decode the JSON response."...
Disable wporg updates for premium products. @param string $r Update payload. @param string $url The api url. @return mixed List of themes to check for update.
[ "Disable", "wporg", "updates", "for", "premium", "products", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L66-L81
46,130
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.register_settings
public function register_settings() { if ( ! is_admin() ) { return false; } add_settings_field( $this->product->get_key() . '_license', $this->product->get_name() . ' license', array( $this, 'license_view' ), 'general' ); }
php
public function register_settings() { if ( ! is_admin() ) { return false; } add_settings_field( $this->product->get_key() . '_license', $this->product->get_name() . ' license', array( $this, 'license_view' ), 'general' ); }
[ "public", "function", "register_settings", "(", ")", "{", "if", "(", "!", "is_admin", "(", ")", ")", "{", "return", "false", ";", "}", "add_settings_field", "(", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_license'", ",", "$", "thi...
Register the setting for the license of the product. @return bool
[ "Register", "the", "setting", "for", "the", "license", "of", "the", "product", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L88-L98
46,131
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.license_view
public function license_view() { $status = $this->get_license_status(); $value = $this->license_key; $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' ); $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' ); $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' ); $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' ); $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' ); echo '<p ><input ' . ( ( 'valid' === $status ) ? ( 'style="border:1px solid #7ad03a; "' ) : '' ) . ' type="text" id="' . $this->product->get_key() . '_license" name="' . $this->product->get_key() . '_license" value="' . $value . '" /><a ' . ( ( 'valid' === $status ) ? ( 'style="color:#fff;background: #7ad03a; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $valid_string ) : ( 'style="color:#fff;background: #dd3d36; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $invalid_string ) ) . ' </a>&nbsp;&nbsp;&nbsp;<button name="' . $this->product->get_key() . '_btn_trigger" ' . ( ( 'valid' === $status ) ? ( ' class="button button-primary">' . $deactivate_string ) : ( ' class="button button-primary" value="yes" type="submit" >' . $activate_string ) ) . ' </button></p><p class="description">' . sprintf( $license_message, '<a href="' . $this->get_api_url() . '">' . $this->get_distributor_name() . '</a> ', $this->product->get_type() ) . '</p>'; }
php
public function license_view() { $status = $this->get_license_status(); $value = $this->license_key; $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' ); $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' ); $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' ); $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' ); $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' ); echo '<p ><input ' . ( ( 'valid' === $status ) ? ( 'style="border:1px solid #7ad03a; "' ) : '' ) . ' type="text" id="' . $this->product->get_key() . '_license" name="' . $this->product->get_key() . '_license" value="' . $value . '" /><a ' . ( ( 'valid' === $status ) ? ( 'style="color:#fff;background: #7ad03a; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $valid_string ) : ( 'style="color:#fff;background: #dd3d36; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $invalid_string ) ) . ' </a>&nbsp;&nbsp;&nbsp;<button name="' . $this->product->get_key() . '_btn_trigger" ' . ( ( 'valid' === $status ) ? ( ' class="button button-primary">' . $deactivate_string ) : ( ' class="button button-primary" value="yes" type="submit" >' . $activate_string ) ) . ' </button></p><p class="description">' . sprintf( $license_message, '<a href="' . $this->get_api_url() . '">' . $this->get_distributor_name() . '</a> ', $this->product->get_type() ) . '</p>'; }
[ "public", "function", "license_view", "(", ")", "{", "$", "status", "=", "$", "this", "->", "get_license_status", "(", ")", ";", "$", "value", "=", "$", "this", "->", "license_key", ";", "$", "activate_string", "=", "apply_filters", "(", "$", "this", "->...
The license view field.
[ "The", "license", "view", "field", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L103-L115
46,132
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.get_license_status
public function get_license_status() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return get_option( $this->product->get_key() . '_license_status', 'not_active' ); } return isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' ); }
php
public function get_license_status() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return get_option( $this->product->get_key() . '_license_status', 'not_active' ); } return isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' ); }
[ "public", "function", "get_license_status", "(", ")", "{", "$", "license_data", "=", "get_option", "(", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_license_data'", ",", "''", ")", ";", "if", "(", "''", "===", "$", "license_data", ")"...
Return the license status. @return string The License status.
[ "Return", "the", "license", "status", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L122-L132
46,133
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.show_notice
function show_notice() { if ( ! is_admin() ) { return false; } $status = $this->get_license_status(); $no_activations_string = apply_filters( $this->product->get_key() . '_lc_no_activations_string', 'No activations left for %s !!!. You need to upgrade your plan in order to use %s on more websites. Please ask the %s Staff for more details.' ); $no_valid_string = apply_filters( $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s, please add your license code from your <a href="%s" target="_blank">purchase history</a> and validate it <a href="%s">here</a>. ' ); $expiration_string = apply_filters( $this->product->get_key() . '_lc_expiration_string', 'Your license is about to expire for %s. You can go to %s and renew it ' ); // No activations left for this license. if ( 'valid' != $status && $this->check_activation() ) { ?> <div class="error"> <p><strong> <?php echo sprintf( $no_activations_string, $this->product->get_name(), $this->product->get_name(), '<a href="' . $this->get_api_url() . '" target="_blank">' . $this->get_distributor_name() . '</a>' ); ?> </strong> </p> </div> <?php return false; } // Invalid license key. if ( 'valid' != $status ) { ?> <div class="error"> <p> <strong><?php echo sprintf( $no_valid_string, $this->product->get_name() . ' ' . $this->product->get_type(), $this->get_api_url(), admin_url( 'options-general.php' ) . '#' . $this->product->get_key() ); ?> </strong> </p> </div> <?php return false; } // Expired and soon to expire license. if ( 'valid' == $status && $this->check_expiration() ) { ?> <div class="update-nag"> <p> <strong> <?php echo sprintf( $expiration_string, $this->product->get_name() . ' ' . $this->product->get_type(), '<a href="' . $this->renew_url() . '" target="_blank">' . $this->get_distributor_name() . '</a>' ); ?> </strong> </p> </div> <?php return false; } return true; }
php
function show_notice() { if ( ! is_admin() ) { return false; } $status = $this->get_license_status(); $no_activations_string = apply_filters( $this->product->get_key() . '_lc_no_activations_string', 'No activations left for %s !!!. You need to upgrade your plan in order to use %s on more websites. Please ask the %s Staff for more details.' ); $no_valid_string = apply_filters( $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s, please add your license code from your <a href="%s" target="_blank">purchase history</a> and validate it <a href="%s">here</a>. ' ); $expiration_string = apply_filters( $this->product->get_key() . '_lc_expiration_string', 'Your license is about to expire for %s. You can go to %s and renew it ' ); // No activations left for this license. if ( 'valid' != $status && $this->check_activation() ) { ?> <div class="error"> <p><strong> <?php echo sprintf( $no_activations_string, $this->product->get_name(), $this->product->get_name(), '<a href="' . $this->get_api_url() . '" target="_blank">' . $this->get_distributor_name() . '</a>' ); ?> </strong> </p> </div> <?php return false; } // Invalid license key. if ( 'valid' != $status ) { ?> <div class="error"> <p> <strong><?php echo sprintf( $no_valid_string, $this->product->get_name() . ' ' . $this->product->get_type(), $this->get_api_url(), admin_url( 'options-general.php' ) . '#' . $this->product->get_key() ); ?> </strong> </p> </div> <?php return false; } // Expired and soon to expire license. if ( 'valid' == $status && $this->check_expiration() ) { ?> <div class="update-nag"> <p> <strong> <?php echo sprintf( $expiration_string, $this->product->get_name() . ' ' . $this->product->get_type(), '<a href="' . $this->renew_url() . '" target="_blank">' . $this->get_distributor_name() . '</a>' ); ?> </strong> </p> </div> <?php return false; } return true; }
[ "function", "show_notice", "(", ")", "{", "if", "(", "!", "is_admin", "(", ")", ")", "{", "return", "false", ";", "}", "$", "status", "=", "$", "this", "->", "get_license_status", "(", ")", ";", "$", "no_activations_string", "=", "apply_filters", "(", ...
Show the admin notice regarding the license status. @return bool Should we show the notice ?
[ "Show", "the", "admin", "notice", "regarding", "the", "license", "status", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L165-L227
46,134
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.check_activation
public function check_activation() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return false; } return isset( $license_data->error ) ? ( 'no_activations_left' == $license_data->error ) : false; }
php
public function check_activation() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return false; } return isset( $license_data->error ) ? ( 'no_activations_left' == $license_data->error ) : false; }
[ "public", "function", "check_activation", "(", ")", "{", "$", "license_data", "=", "get_option", "(", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_license_data'", ",", "''", ")", ";", "if", "(", "''", "===", "$", "license_data", ")", ...
Check if the license is active or not. @return bool
[ "Check", "if", "the", "license", "is", "active", "or", "not", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L234-L242
46,135
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.check_expiration
function check_expiration() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return false; } if ( ! isset( $license_data->expires ) ) { return false; } if ( strtotime( $license_data->expires ) - time() > 30 * 24 * 3600 ) { return false; } return true; }
php
function check_expiration() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return false; } if ( ! isset( $license_data->expires ) ) { return false; } if ( strtotime( $license_data->expires ) - time() > 30 * 24 * 3600 ) { return false; } return true; }
[ "function", "check_expiration", "(", ")", "{", "$", "license_data", "=", "get_option", "(", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_license_data'", ",", "''", ")", ";", "if", "(", "''", "===", "$", "license_data", ")", "{", "re...
Check if the license is about to expire in the next month. @return bool
[ "Check", "if", "the", "license", "is", "about", "to", "expire", "in", "the", "next", "month", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L249-L262
46,136
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.renew_url
function renew_url() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return $this->get_api_url(); } if ( ! isset( $license_data->download_id ) || ! isset( $license_data->key ) ) { return $this->get_api_url(); } return $this->get_api_url() . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id; }
php
function renew_url() { $license_data = get_option( $this->product->get_key() . '_license_data', '' ); if ( '' === $license_data ) { return $this->get_api_url(); } if ( ! isset( $license_data->download_id ) || ! isset( $license_data->key ) ) { return $this->get_api_url(); } return $this->get_api_url() . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id; }
[ "function", "renew_url", "(", ")", "{", "$", "license_data", "=", "get_option", "(", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_license_data'", ",", "''", ")", ";", "if", "(", "''", "===", "$", "license_data", ")", "{", "return", ...
Return the renew url from the store used. @return string The renew url.
[ "Return", "the", "renew", "url", "from", "the", "store", "used", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L269-L279
46,137
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.product_valid
public function product_valid() { if ( false !== ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) { return; } $license = $this->check_license(); set_transient( $this->product->get_key() . '_license_data', $license, 12 * HOUR_IN_SECONDS ); update_option( $this->product->get_key() . '_license_data', $license ); }
php
public function product_valid() { if ( false !== ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) { return; } $license = $this->check_license(); set_transient( $this->product->get_key() . '_license_data', $license, 12 * HOUR_IN_SECONDS ); update_option( $this->product->get_key() . '_license_data', $license ); }
[ "public", "function", "product_valid", "(", ")", "{", "if", "(", "false", "!==", "(", "$", "license", "=", "get_transient", "(", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_license_data'", ")", ")", ")", "{", "return", ";", "}", ...
Run the license check call.
[ "Run", "the", "license", "check", "call", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L284-L291
46,138
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.check_license
public function check_license() { $status = $this->get_license_status(); if ( 'not_active' == $status ) { $license_data = new \stdClass(); $license_data->license = 'not_active'; return $license_data; } $license = trim( $this->license_key ); $api_params = array( 'edd_action' => 'check_license', 'license' => $license, 'item_name' => rawurlencode( $this->product->get_name() ), 'url' => rawurlencode( home_url() ), ); // Call the custom API. $response = wp_remote_get( add_query_arg( $api_params, $this->get_api_url() ), array( 'timeout' => 15, 'sslverify' => false, ) ); if ( is_wp_error( $response ) ) { $license_data = new \stdClass(); $license_data->license = 'valid'; } else { $license_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $license_data ) ) { $license_data = new \stdClass(); $license_data->license = 'valid'; } } $license_old = get_option( $this->product->get_key() . '_license_data', '' ); if ( 'valid' == $license_old->license && ( $license_data->license != $license_old->license ) ) { $this->increment_failed_checks(); } else { $this->reset_failed_checks(); } if ( $this->failed_checks <= self::$max_failed ) { return $license_old; } if ( isset( $license_old->hide_valid ) ) { $license_data->hide_valid = true; } if ( ! isset( $license_data->key ) ) { $license_data->key = isset( $license_old->key ) ? $license_old->key : ''; } if ( isset( $license_old->hide_expiration ) ) { $license_data->hide_expiration = true; } if ( isset( $license_old->hide_activation ) ) { $license_data->hide_activation = true; } return $license_data; }
php
public function check_license() { $status = $this->get_license_status(); if ( 'not_active' == $status ) { $license_data = new \stdClass(); $license_data->license = 'not_active'; return $license_data; } $license = trim( $this->license_key ); $api_params = array( 'edd_action' => 'check_license', 'license' => $license, 'item_name' => rawurlencode( $this->product->get_name() ), 'url' => rawurlencode( home_url() ), ); // Call the custom API. $response = wp_remote_get( add_query_arg( $api_params, $this->get_api_url() ), array( 'timeout' => 15, 'sslverify' => false, ) ); if ( is_wp_error( $response ) ) { $license_data = new \stdClass(); $license_data->license = 'valid'; } else { $license_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $license_data ) ) { $license_data = new \stdClass(); $license_data->license = 'valid'; } } $license_old = get_option( $this->product->get_key() . '_license_data', '' ); if ( 'valid' == $license_old->license && ( $license_data->license != $license_old->license ) ) { $this->increment_failed_checks(); } else { $this->reset_failed_checks(); } if ( $this->failed_checks <= self::$max_failed ) { return $license_old; } if ( isset( $license_old->hide_valid ) ) { $license_data->hide_valid = true; } if ( ! isset( $license_data->key ) ) { $license_data->key = isset( $license_old->key ) ? $license_old->key : ''; } if ( isset( $license_old->hide_expiration ) ) { $license_data->hide_expiration = true; } if ( isset( $license_old->hide_activation ) ) { $license_data->hide_activation = true; } return $license_data; }
[ "public", "function", "check_license", "(", ")", "{", "$", "status", "=", "$", "this", "->", "get_license_status", "(", ")", ";", "if", "(", "'not_active'", "==", "$", "status", ")", "{", "$", "license_data", "=", "new", "\\", "stdClass", "(", ")", ";"...
Check the license status. @return object The license data.
[ "Check", "the", "license", "status", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L298-L361
46,139
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.activate_license
function activate_license() { // listen for our activate button to be clicked. if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) { return; } $status = $this->get_license_status(); // retrieve the license from the database. $license = $_POST[ $this->product->get_key() . '_license' ]; $api_params = array( 'license' => $license, 'item_name' => rawurlencode( $this->product->get_name() ), 'url' => rawurlencode( home_url() ), ); if ( 'valid' != $status ) { // data to send in our API request. $api_params['edd_action'] = 'activate_license'; } else { $api_params['edd_action'] = 'deactivate_license'; } // Call the custom API. $response = wp_remote_get( add_query_arg( $api_params, $this->get_api_url() ) ); // make sure the response came back okay. if ( is_wp_error( $response ) ) { $license_data = new \stdClass(); $license_data->license = ( 'valid' != $status ) ? 'valid' : 'invalid'; } else { $license_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $license_data ) ) { $license_data = new \stdClass(); $license_data->license = ( 'valid' != $status ) ? 'valid' : 'invalid'; } if ( ! isset( $license_data->license ) ) { $license_data->license = 'invalid'; } } if ( ! isset( $license_data->key ) ) { $license_data->key = $license; } if ( 'valid' == $license_data->license ) { $this->reset_failed_checks(); } if ( isset( $license_data->plan ) ) { update_option( $this->product->get_key() . '_license_plan', $license_data->plan ); } update_option( $this->product->get_key() . '_license_data', $license_data ); set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS ); }
php
function activate_license() { // listen for our activate button to be clicked. if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) { return; } $status = $this->get_license_status(); // retrieve the license from the database. $license = $_POST[ $this->product->get_key() . '_license' ]; $api_params = array( 'license' => $license, 'item_name' => rawurlencode( $this->product->get_name() ), 'url' => rawurlencode( home_url() ), ); if ( 'valid' != $status ) { // data to send in our API request. $api_params['edd_action'] = 'activate_license'; } else { $api_params['edd_action'] = 'deactivate_license'; } // Call the custom API. $response = wp_remote_get( add_query_arg( $api_params, $this->get_api_url() ) ); // make sure the response came back okay. if ( is_wp_error( $response ) ) { $license_data = new \stdClass(); $license_data->license = ( 'valid' != $status ) ? 'valid' : 'invalid'; } else { $license_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $license_data ) ) { $license_data = new \stdClass(); $license_data->license = ( 'valid' != $status ) ? 'valid' : 'invalid'; } if ( ! isset( $license_data->license ) ) { $license_data->license = 'invalid'; } } if ( ! isset( $license_data->key ) ) { $license_data->key = $license; } if ( 'valid' == $license_data->license ) { $this->reset_failed_checks(); } if ( isset( $license_data->plan ) ) { update_option( $this->product->get_key() . '_license_plan', $license_data->plan ); } update_option( $this->product->get_key() . '_license_data', $license_data ); set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS ); }
[ "function", "activate_license", "(", ")", "{", "// listen for our activate button to be clicked.", "if", "(", "!", "isset", "(", "$", "_POST", "[", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_btn_trigger'", "]", ")", ")", "{", "return", ...
Activate the license remotely.
[ "Activate", "the", "license", "remotely", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L382-L432
46,140
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.update_nag
function update_nag() { $theme = wp_get_theme( $this->product->get_slug() ); $api_response = get_transient( $this->product_key ); if ( false === $api_response ) { return; } $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() ); $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' ); $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { echo '<div id="update-nag">'; printf( '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.', $theme->get( 'Name' ), $api_response->new_version, '#TB_inline?width=640&amp;inlineId=' . $this->product->get_version() . '_changelog', $theme->get( 'Name' ), $update_url, $update_onclick ); echo '</div>'; echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">'; echo wpautop( $api_response->sections['changelog'] ); echo '</div>'; } }
php
function update_nag() { $theme = wp_get_theme( $this->product->get_slug() ); $api_response = get_transient( $this->product_key ); if ( false === $api_response ) { return; } $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() ); $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' ); $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { echo '<div id="update-nag">'; printf( '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.', $theme->get( 'Name' ), $api_response->new_version, '#TB_inline?width=640&amp;inlineId=' . $this->product->get_version() . '_changelog', $theme->get( 'Name' ), $update_url, $update_onclick ); echo '</div>'; echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">'; echo wpautop( $api_response->sections['changelog'] ); echo '</div>'; } }
[ "function", "update_nag", "(", ")", "{", "$", "theme", "=", "wp_get_theme", "(", "$", "this", "->", "product", "->", "get_slug", "(", ")", ")", ";", "$", "api_response", "=", "get_transient", "(", "$", "this", "->", "product_key", ")", ";", "if", "(", ...
Alter the nag for themes update.
[ "Alter", "the", "nag", "for", "themes", "update", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L445-L470
46,141
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.theme_update_transient
function theme_update_transient( $value ) { $update_data = $this->check_for_update(); if ( $update_data ) { $value->response[ $this->product->get_slug() ] = $update_data; } return $value; }
php
function theme_update_transient( $value ) { $update_data = $this->check_for_update(); if ( $update_data ) { $value->response[ $this->product->get_slug() ] = $update_data; } return $value; }
[ "function", "theme_update_transient", "(", "$", "value", ")", "{", "$", "update_data", "=", "$", "this", "->", "check_for_update", "(", ")", ";", "if", "(", "$", "update_data", ")", "{", "$", "value", "->", "response", "[", "$", "this", "->", "product", ...
Alter update transient. @param mixed $value The transient data. @return mixed
[ "Alter", "update", "transient", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L479-L486
46,142
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.check_for_update
function check_for_update() { $update_data = get_transient( $this->product_key ); if ( false === $update_data ) { $failed = false; $update_data = $this->get_version_data(); if ( empty( $update_data ) ) { $failed = true; } // If the response failed, try again in 30 minutes. if ( $failed ) { $data = new \stdClass(); $data->new_version = $this->product->get_version(); set_transient( $this->product_key, $data, 30 * MINUTE_IN_SECONDS ); return false; } $update_data->sections = maybe_unserialize( $update_data->sections ); set_transient( $this->product_key, $update_data, 12 * HOUR_IN_SECONDS ); } if ( ! isset( $update_data->new_version ) ) { return false; } if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) { return false; } return (array) $update_data; }
php
function check_for_update() { $update_data = get_transient( $this->product_key ); if ( false === $update_data ) { $failed = false; $update_data = $this->get_version_data(); if ( empty( $update_data ) ) { $failed = true; } // If the response failed, try again in 30 minutes. if ( $failed ) { $data = new \stdClass(); $data->new_version = $this->product->get_version(); set_transient( $this->product_key, $data, 30 * MINUTE_IN_SECONDS ); return false; } $update_data->sections = maybe_unserialize( $update_data->sections ); set_transient( $this->product_key, $update_data, 12 * HOUR_IN_SECONDS ); } if ( ! isset( $update_data->new_version ) ) { return false; } if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) { return false; } return (array) $update_data; }
[ "function", "check_for_update", "(", ")", "{", "$", "update_data", "=", "get_transient", "(", "$", "this", "->", "product_key", ")", ";", "if", "(", "false", "===", "$", "update_data", ")", "{", "$", "failed", "=", "false", ";", "$", "update_data", "=", ...
Check for updates @return array|bool Either the update data or false in case of failure.
[ "Check", "for", "updates" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L493-L522
46,143
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.get_version_data
private function get_version_data() { $api_params = array( 'edd_action' => 'get_version', 'version' => $this->product->get_version(), 'license' => $this->license_key, 'name' => $this->product->get_name(), 'slug' => $this->product->get_slug(), 'author' => $this->get_distributor_name(), 'url' => rawurlencode( home_url() ), ); $response = wp_remote_get( $this->get_api_url(), array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params, ) ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { return false; } $update_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $update_data ) ) { return false; } return $update_data; }
php
private function get_version_data() { $api_params = array( 'edd_action' => 'get_version', 'version' => $this->product->get_version(), 'license' => $this->license_key, 'name' => $this->product->get_name(), 'slug' => $this->product->get_slug(), 'author' => $this->get_distributor_name(), 'url' => rawurlencode( home_url() ), ); $response = wp_remote_get( $this->get_api_url(), array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params, ) ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { return false; } $update_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $update_data ) ) { return false; } return $update_data; }
[ "private", "function", "get_version_data", "(", ")", "{", "$", "api_params", "=", "array", "(", "'edd_action'", "=>", "'get_version'", ",", "'version'", "=>", "$", "this", "->", "product", "->", "get_version", "(", ")", ",", "'license'", "=>", "$", "this", ...
Check remote api for latest version. @return bool|mixed Update api response.
[ "Check", "remote", "api", "for", "latest", "version", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L529-L556
46,144
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.http_request_args
function http_request_args( $args, $url ) { // If it is an https request and we are performing a package download, disable ssl verification. if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { $args['sslverify'] = false; } return $args; }
php
function http_request_args( $args, $url ) { // If it is an https request and we are performing a package download, disable ssl verification. if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { $args['sslverify'] = false; } return $args; }
[ "function", "http_request_args", "(", "$", "args", ",", "$", "url", ")", "{", "// If it is an https request and we are performing a package download, disable ssl verification.", "if", "(", "strpos", "(", "$", "url", ",", "'https://'", ")", "!==", "false", "&&", "strpos"...
Disable SSL verification in order to prevent download update failures. @param array $args Http args. @param string $url Url to check. @return array $array
[ "Disable", "SSL", "verification", "in", "order", "to", "prevent", "download", "update", "failures", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L637-L644
46,145
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.can_load
public function can_load( $product ) { if ( $product->is_wordpress_available() ) { return false; } return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true ); }
php
public function can_load( $product ) { if ( $product->is_wordpress_available() ) { return false; } return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true ); }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "product", "->", "is_wordpress_available", "(", ")", ")", "{", "return", "false", ";", "}", "return", "(", "apply_filters", "(", "$", "product", "->", "get_key", "(", ")", ...
Check if we should load the module for this product. @param Product $product Product data. @return bool Should we load the module?
[ "Check", "if", "we", "should", "load", "the", "module", "for", "this", "product", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L653-L661
46,146
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.register_license_hooks
public function register_license_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'activate_license' ) ); add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 ); add_action( 'admin_notices', array( $this, 'show_notice' ) ); add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) ); }
php
public function register_license_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'activate_license' ) ); add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 ); add_action( 'admin_notices', array( $this, 'show_notice' ) ); add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) ); }
[ "public", "function", "register_license_hooks", "(", ")", "{", "add_action", "(", "'admin_init'", ",", "array", "(", "$", "this", ",", "'register_settings'", ")", ")", ";", "add_action", "(", "'admin_init'", ",", "array", "(", "$", "this", ",", "'activate_lice...
Register license fields for the products.
[ "Register", "license", "fields", "for", "the", "products", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L712-L718
46,147
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.show_notification
public static function show_notification() { $current_notification = self::get_last_notification(); $notification_details = []; // Check if the saved notification is still present among the possible ones. if ( ! empty( $current_notification ) ) { $notification_details = self::get_notification_details( $current_notification ); if ( empty( $notification_details ) ) { $current_notification = []; } } // Check if the notificatin is expired. if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) { update_option( $current_notification['id'], 'no' ); self::set_last_active_notification_timestamp(); $current_notification = []; } // If we don't have any saved notification, get a new one. if ( empty( $current_notification ) ) { $notification_details = self::get_random_notification(); if ( empty( $notification_details ) ) { return; } self::set_active_notification( [ 'id' => $notification_details['id'], 'display_at' => time(), ] ); } if ( empty( $notification_details ) ) { return; } $notification_html = self::get_notification_html( $notification_details ); do_action( $notification_details['id'] . '_before_render' ); echo $notification_html; do_action( $notification_details['id'] . '_after_render' ); self::render_snippets(); }
php
public static function show_notification() { $current_notification = self::get_last_notification(); $notification_details = []; // Check if the saved notification is still present among the possible ones. if ( ! empty( $current_notification ) ) { $notification_details = self::get_notification_details( $current_notification ); if ( empty( $notification_details ) ) { $current_notification = []; } } // Check if the notificatin is expired. if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) { update_option( $current_notification['id'], 'no' ); self::set_last_active_notification_timestamp(); $current_notification = []; } // If we don't have any saved notification, get a new one. if ( empty( $current_notification ) ) { $notification_details = self::get_random_notification(); if ( empty( $notification_details ) ) { return; } self::set_active_notification( [ 'id' => $notification_details['id'], 'display_at' => time(), ] ); } if ( empty( $notification_details ) ) { return; } $notification_html = self::get_notification_html( $notification_details ); do_action( $notification_details['id'] . '_before_render' ); echo $notification_html; do_action( $notification_details['id'] . '_after_render' ); self::render_snippets(); }
[ "public", "static", "function", "show_notification", "(", ")", "{", "$", "current_notification", "=", "self", "::", "get_last_notification", "(", ")", ";", "$", "notification_details", "=", "[", "]", ";", "// Check if the saved notification is still present among the poss...
Show notification data.
[ "Show", "notification", "data", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L50-L91
46,148
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.get_notification_details
private static function get_notification_details( $notification ) { $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); return ! empty( $notifications ) ? reset( $notifications ) : []; }
php
private static function get_notification_details( $notification ) { $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); return ! empty( $notifications ) ? reset( $notifications ) : []; }
[ "private", "static", "function", "get_notification_details", "(", "$", "notification", ")", "{", "$", "notifications", "=", "array_filter", "(", "self", "::", "$", "notifications", ",", "function", "(", "$", "value", ")", "use", "(", "$", "notification", ")", ...
Check if the notification is still possible. @param array $notification Notification to check. @return array Either is still active or not.
[ "Check", "if", "the", "notification", "is", "still", "possible", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L130-L143
46,149
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.is_notification_expired
private static function is_notification_expired( $notification ) { if ( ! isset( $notification['display_at'] ) ) { return true; } $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); if ( empty( $notifications ) ) { return true; } $notification_definition = reset( $notifications ); $when_to_expire = isset( $notification_definition['expires_at'] ) ? $notification_definition['expires_at'] : ( isset( $notification_definition['expires'] ) ? ( $notification['display_at'] + $notification_definition['expires'] ) : ( $notification['display_at'] + self::MAX_TIME_TO_LIVE * DAY_IN_SECONDS ) ); return ( $when_to_expire - time() ) < 0; }
php
private static function is_notification_expired( $notification ) { if ( ! isset( $notification['display_at'] ) ) { return true; } $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); if ( empty( $notifications ) ) { return true; } $notification_definition = reset( $notifications ); $when_to_expire = isset( $notification_definition['expires_at'] ) ? $notification_definition['expires_at'] : ( isset( $notification_definition['expires'] ) ? ( $notification['display_at'] + $notification_definition['expires'] ) : ( $notification['display_at'] + self::MAX_TIME_TO_LIVE * DAY_IN_SECONDS ) ); return ( $when_to_expire - time() ) < 0; }
[ "private", "static", "function", "is_notification_expired", "(", "$", "notification", ")", "{", "if", "(", "!", "isset", "(", "$", "notification", "[", "'display_at'", "]", ")", ")", "{", "return", "true", ";", "}", "$", "notifications", "=", "array_filter",...
Check if the notification is expired. @param array $notification Notification to check. @return bool Either the notification is due.
[ "Check", "if", "the", "notification", "is", "expired", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L152-L181
46,150
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.get_random_notification
public static function get_random_notification() { if ( ( time() - self::get_last_active_notification_timestamp() ) < self::TIME_BETWEEN_NOTIFICATIONS * DAY_IN_SECONDS ) { return []; } $notifications = self::$notifications; $notifications = array_filter( $notifications, function ( $value ) { if ( isset( $value['sticky'] ) && true === $value['sticky'] ) { return true; } return false; } ); // No priority notifications, use all. if ( empty( $notifications ) ) { $notifications = self::$notifications; } if ( empty( $notifications ) ) { return []; } $notifications = array_values( $notifications ); return $notifications[ array_rand( $notifications, 1 ) ]; }
php
public static function get_random_notification() { if ( ( time() - self::get_last_active_notification_timestamp() ) < self::TIME_BETWEEN_NOTIFICATIONS * DAY_IN_SECONDS ) { return []; } $notifications = self::$notifications; $notifications = array_filter( $notifications, function ( $value ) { if ( isset( $value['sticky'] ) && true === $value['sticky'] ) { return true; } return false; } ); // No priority notifications, use all. if ( empty( $notifications ) ) { $notifications = self::$notifications; } if ( empty( $notifications ) ) { return []; } $notifications = array_values( $notifications ); return $notifications[ array_rand( $notifications, 1 ) ]; }
[ "public", "static", "function", "get_random_notification", "(", ")", "{", "if", "(", "(", "time", "(", ")", "-", "self", "::", "get_last_active_notification_timestamp", "(", ")", ")", "<", "self", "::", "TIME_BETWEEN_NOTIFICATIONS", "*", "DAY_IN_SECONDS", ")", "...
Return notification to show. @return array Notification data.
[ "Return", "notification", "to", "show", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L197-L224
46,151
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.get_notification_html
public static function get_notification_html( $notification_details ) { $default = [ 'id' => '', 'heading' => '', 'message' => '', 'ctas' => [ 'confirm' => [ 'link' => '#', 'text' => '', ], 'cancel' => [ 'link' => '#', 'text' => '', ], ], ]; $notification_details = wp_parse_args( $notification_details, $default ); $notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">'; if ( ! empty( $notification_details['heading'] ) ) { $notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) ); } if ( ! empty( $notification_details['message'] ) ) { $notification_html .= wp_kses_post( $notification_details['message'] ); } $notification_html .= '<div class="actions">'; if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" target="_blank" class=" button button-primary %s" data-confirm="yes" >%s</a>', esc_url( $notification_details['ctas']['confirm']['link'] ), esc_attr( $notification_details['id'] . '_confirm' ), wp_kses_post( $notification_details['ctas']['confirm']['text'] ) ); } if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" class=" button %s" data-confirm="no">%s</a>', esc_url( $notification_details['ctas']['cancel']['link'] ), esc_attr( $notification_details['id'] ) . '_cancel', wp_kses_post( $notification_details['ctas']['cancel']['text'] ) ); } $notification_html .= '</div>'; $notification_html .= ' </div>'; $notification_html .= ' </div>'; return $notification_html; }
php
public static function get_notification_html( $notification_details ) { $default = [ 'id' => '', 'heading' => '', 'message' => '', 'ctas' => [ 'confirm' => [ 'link' => '#', 'text' => '', ], 'cancel' => [ 'link' => '#', 'text' => '', ], ], ]; $notification_details = wp_parse_args( $notification_details, $default ); $notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">'; if ( ! empty( $notification_details['heading'] ) ) { $notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) ); } if ( ! empty( $notification_details['message'] ) ) { $notification_html .= wp_kses_post( $notification_details['message'] ); } $notification_html .= '<div class="actions">'; if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" target="_blank" class=" button button-primary %s" data-confirm="yes" >%s</a>', esc_url( $notification_details['ctas']['confirm']['link'] ), esc_attr( $notification_details['id'] . '_confirm' ), wp_kses_post( $notification_details['ctas']['confirm']['text'] ) ); } if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" class=" button %s" data-confirm="no">%s</a>', esc_url( $notification_details['ctas']['cancel']['link'] ), esc_attr( $notification_details['id'] ) . '_cancel', wp_kses_post( $notification_details['ctas']['cancel']['text'] ) ); } $notification_html .= '</div>'; $notification_html .= ' </div>'; $notification_html .= ' </div>'; return $notification_html; }
[ "public", "static", "function", "get_notification_html", "(", "$", "notification_details", ")", "{", "$", "default", "=", "[", "'id'", "=>", "''", ",", "'heading'", "=>", "''", ",", "'message'", "=>", "''", ",", "'ctas'", "=>", "[", "'confirm'", "=>", "[",...
Get notification html. @param array $notification_details Notification details. @return string Html for notice.
[ "Get", "notification", "html", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L255-L306
46,152
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.dismiss
static function dismiss() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : ''; $confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no'; if ( empty( $id ) ) { wp_send_json( [] ); } self::set_last_active_notification_timestamp(); update_option( $id, $confirm ); do_action( $id . '_process_confirm', $confirm ); wp_send_json( [] ); }
php
static function dismiss() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : ''; $confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no'; if ( empty( $id ) ) { wp_send_json( [] ); } self::set_last_active_notification_timestamp(); update_option( $id, $confirm ); do_action( $id . '_process_confirm', $confirm ); wp_send_json( [] ); }
[ "static", "function", "dismiss", "(", ")", "{", "check_ajax_referer", "(", "(", "string", ")", "__CLASS__", ",", "'nonce'", ")", ";", "$", "id", "=", "isset", "(", "$", "_POST", "[", "'id'", "]", ")", "?", "sanitize_text_field", "(", "$", "_POST", "[",...
Dismiss the notification.
[ "Dismiss", "the", "notification", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L368-L381
46,153
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! current_user_can( 'manage_options' ) ) { return false; } if ( ( time() - $product->get_install_time() ) < ( self::MIN_INSTALL_TIME * HOUR_IN_SECONDS ) ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! current_user_can( 'manage_options' ) ) { return false; } if ( ( time() - $product->get_install_time() ) < ( self::MIN_INSTALL_TIME * HOUR_IN_SECONDS ) ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "current_user_can", "(", "'manage_options'", ")", ")", "{...
Check if we should load the notification module. @param Product $product Product to check. @return bool Should we load this?
[ "Check", "if", "we", "should", "load", "the", "notification", "module", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L390-L403
46,154
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.setup_notifications
public static function setup_notifications() { $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; }
php
public static function setup_notifications() { $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; }
[ "public", "static", "function", "setup_notifications", "(", ")", "{", "$", "notifications", "=", "apply_filters", "(", "'themeisle_sdk_registered_notifications'", ",", "[", "]", ")", ";", "$", "notifications", "=", "array_filter", "(", "$", "notifications", ",", "...
Setup notifications queue.
[ "Setup", "notifications", "queue", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L408-L424
46,155
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.load
public function load( $product ) { $this->product = $product; $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) ); add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) ); add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) ); return $this; }
php
public function load( $product ) { $this->product = $product; $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) ); add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) ); add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) ); return $this; }
[ "public", "function", "load", "(", "$", "product", ")", "{", "$", "this", "->", "product", "=", "$", "product", ";", "$", "notifications", "=", "apply_filters", "(", "'themeisle_sdk_registered_notifications'", ",", "[", "]", ")", ";", "$", "notifications", "...
Load the module logic. @param Product $product Product to load the module for. @return Notification Module instance.
[ "Load", "the", "module", "logic", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L432-L455
46,156
Codeinwp/themeisle-sdk
src/Modules/Logger.php
Logger.setup_actions
public function setup_actions() { if ( ! $this->is_logger_active() ) { return; } $action_key = $this->product->get_key() . '_log_activity'; if ( ! wp_next_scheduled( $action_key ) ) { wp_schedule_single_event( time() + ( rand( 1, 24 ) * 3600 ), $action_key ); } add_action( $action_key, array( $this, 'send_log' ) ); }
php
public function setup_actions() { if ( ! $this->is_logger_active() ) { return; } $action_key = $this->product->get_key() . '_log_activity'; if ( ! wp_next_scheduled( $action_key ) ) { wp_schedule_single_event( time() + ( rand( 1, 24 ) * 3600 ), $action_key ); } add_action( $action_key, array( $this, 'send_log' ) ); }
[ "public", "function", "setup_actions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_logger_active", "(", ")", ")", "{", "return", ";", "}", "$", "action_key", "=", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_log_activity'"...
Setup tracking actions.
[ "Setup", "tracking", "actions", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Logger.php#L75-L85
46,157
Codeinwp/themeisle-sdk
src/Modules/Logger.php
Logger.is_logger_active
private function is_logger_active() { if ( ! $this->product->is_wordpress_available() ) { return true; } $pro_slug = $this->product->get_pro_slug(); if ( ! empty( $pro_slug ) ) { $all_products = Loader::get_products(); if ( isset( $all_products[ $pro_slug ] ) ) { return true; } } return ( get_option( $this->product->get_key() . '_logger_flag', 'no' ) === 'yes' ); }
php
private function is_logger_active() { if ( ! $this->product->is_wordpress_available() ) { return true; } $pro_slug = $this->product->get_pro_slug(); if ( ! empty( $pro_slug ) ) { $all_products = Loader::get_products(); if ( isset( $all_products[ $pro_slug ] ) ) { return true; } } return ( get_option( $this->product->get_key() . '_logger_flag', 'no' ) === 'yes' ); }
[ "private", "function", "is_logger_active", "(", ")", "{", "if", "(", "!", "$", "this", "->", "product", "->", "is_wordpress_available", "(", ")", ")", "{", "return", "true", ";", "}", "$", "pro_slug", "=", "$", "this", "->", "product", "->", "get_pro_slu...
Check if the logger is active. @return bool Is logger active?
[ "Check", "if", "the", "logger", "is", "active", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Logger.php#L92-L106
46,158
Codeinwp/themeisle-sdk
src/Modules/Logger.php
Logger.send_log
public function send_log() { $environment = array(); $theme = wp_get_theme(); $environment['theme'] = array(); $environment['theme']['name'] = $theme->get( 'Name' ); $environment['theme']['author'] = $theme->get( 'Author' ); $environment['plugins'] = get_option( 'active_plugins' ); global $wp_version; wp_remote_post( self::TRACKING_ENDPOINT, array( 'method' => 'POST', 'timeout' => 3, 'redirection' => 5, 'headers' => array( 'X-ThemeIsle-Event' => 'log_site', ), 'body' => array( 'site' => get_site_url(), 'slug' => $this->product->get_slug(), 'version' => $this->product->get_version(), 'wp_version' => $wp_version, 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ), 'environment' => $environment, 'license' => apply_filters( $this->product->get_key() . '_license_status', '' ), ), ) ); }
php
public function send_log() { $environment = array(); $theme = wp_get_theme(); $environment['theme'] = array(); $environment['theme']['name'] = $theme->get( 'Name' ); $environment['theme']['author'] = $theme->get( 'Author' ); $environment['plugins'] = get_option( 'active_plugins' ); global $wp_version; wp_remote_post( self::TRACKING_ENDPOINT, array( 'method' => 'POST', 'timeout' => 3, 'redirection' => 5, 'headers' => array( 'X-ThemeIsle-Event' => 'log_site', ), 'body' => array( 'site' => get_site_url(), 'slug' => $this->product->get_slug(), 'version' => $this->product->get_version(), 'wp_version' => $wp_version, 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ), 'environment' => $environment, 'license' => apply_filters( $this->product->get_key() . '_license_status', '' ), ), ) ); }
[ "public", "function", "send_log", "(", ")", "{", "$", "environment", "=", "array", "(", ")", ";", "$", "theme", "=", "wp_get_theme", "(", ")", ";", "$", "environment", "[", "'theme'", "]", "=", "array", "(", ")", ";", "$", "environment", "[", "'theme...
Send the statistics to the api endpoint.
[ "Send", "the", "statistics", "to", "the", "api", "endpoint", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Logger.php#L148-L176
46,159
Codeinwp/themeisle-sdk
src/Common/Module_factory.php
Module_Factory.attach
public static function attach( $product, $modules ) { if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) { self::$modules_attached[ $product->get_slug() ] = []; } foreach ( $modules as $module ) { $class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ); /** * Module object. * * @var Abstract_Module $module_object Module instance. */ $module_object = new $class( $product ); if ( ! $module_object->can_load( $product ) ) { continue; } self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product ); } }
php
public static function attach( $product, $modules ) { if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) { self::$modules_attached[ $product->get_slug() ] = []; } foreach ( $modules as $module ) { $class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ); /** * Module object. * * @var Abstract_Module $module_object Module instance. */ $module_object = new $class( $product ); if ( ! $module_object->can_load( $product ) ) { continue; } self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product ); } }
[ "public", "static", "function", "attach", "(", "$", "product", ",", "$", "modules", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "modules_attached", "[", "$", "product", "->", "get_slug", "(", ")", "]", ")", ")", "{", "self", "::", "$...
Load availabe modules for the selected product. @param Product $product Loaded product. @param array $modules List of modules.
[ "Load", "availabe", "modules", "for", "the", "selected", "product", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Common/Module_factory.php#L78-L98
46,160
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! apply_filters( $product->get_slug() . '_load_dashboard_widget', true ) ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! apply_filters( $product->get_slug() . '_load_dashboard_widget', true ) ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "apply_filters", "(", "$", "product", "->", "get_slug", ...
Should we load this module. @param Product $product Product object. @return bool
[ "Should", "we", "load", "this", "module", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L55-L65
46,161
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.load
public function load( $product ) { $this->product = $product; $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' ); $this->feeds = apply_filters( 'themeisle_sdk_dashboard_widget_feeds', [ 'https://themeisle.com/blog/feed', ] ); add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) ); add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) ); add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) ); return $this; }
php
public function load( $product ) { $this->product = $product; $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' ); $this->feeds = apply_filters( 'themeisle_sdk_dashboard_widget_feeds', [ 'https://themeisle.com/blog/feed', ] ); add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) ); add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) ); add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) ); return $this; }
[ "public", "function", "load", "(", "$", "product", ")", "{", "$", "this", "->", "product", "=", "$", "product", ";", "$", "this", "->", "dashboard_name", "=", "apply_filters", "(", "'themeisle_sdk_dashboard_widget_name'", ",", "'WordPress Guides/Tutorials'", ")", ...
Registers the hooks. @param Product $product Product to load. @return Dashboard_Widget Module instance.
[ "Registers", "the", "hooks", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L74-L89
46,162
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.setup_feeds
private function setup_feeds() { if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { // Load SimplePie Instance. $feed = fetch_feed( $this->feeds ); // TODO report error when is an error loading the feed. if ( is_wp_error( $feed ) ) { return; } $items = $feed->get_items( 0, 5 ); foreach ( (array) $items as $item ) { $items_normalized[] = array( 'title' => $item->get_title(), 'date' => $item->get_date( 'U' ), 'link' => $item->get_permalink(), ); } set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS ); } $this->items = $items_normalized; }
php
private function setup_feeds() { if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { // Load SimplePie Instance. $feed = fetch_feed( $this->feeds ); // TODO report error when is an error loading the feed. if ( is_wp_error( $feed ) ) { return; } $items = $feed->get_items( 0, 5 ); foreach ( (array) $items as $item ) { $items_normalized[] = array( 'title' => $item->get_title(), 'date' => $item->get_date( 'U' ), 'link' => $item->get_permalink(), ); } set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS ); } $this->items = $items_normalized; }
[ "private", "function", "setup_feeds", "(", ")", "{", "if", "(", "false", "===", "(", "$", "items_normalized", "=", "get_transient", "(", "'themeisle_sdk_feed_items'", ")", ")", ")", "{", "// Load SimplePie Instance.", "$", "feed", "=", "fetch_feed", "(", "$", ...
Setup feed items.
[ "Setup", "feed", "items", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L305-L325
46,163
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.remove_current_products
public function remove_current_products( $val ) { if ( 'theme' === $val['type'] ) { $exist = wp_get_theme( $val['slug'] ); return ! $exist->exists(); } else { $all_plugins = array_keys( get_plugins() ); foreach ( $all_plugins as $slug ) { if ( strpos( $slug, $val['slug'] ) !== false ) { return false; } } return true; } }
php
public function remove_current_products( $val ) { if ( 'theme' === $val['type'] ) { $exist = wp_get_theme( $val['slug'] ); return ! $exist->exists(); } else { $all_plugins = array_keys( get_plugins() ); foreach ( $all_plugins as $slug ) { if ( strpos( $slug, $val['slug'] ) !== false ) { return false; } } return true; } }
[ "public", "function", "remove_current_products", "(", "$", "val", ")", "{", "if", "(", "'theme'", "===", "$", "val", "[", "'type'", "]", ")", "{", "$", "exist", "=", "wp_get_theme", "(", "$", "val", "[", "'slug'", "]", ")", ";", "return", "!", "$", ...
Either the current product is installed or not. @param array $val The current recommended product. @return bool Either we should exclude the plugin or not.
[ "Either", "the", "current", "product", "is", "installed", "or", "not", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L334-L349
46,164
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.get_product_from_api
function get_product_from_api() { if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { $products = array(); $all_themes = $this->get_themes_from_wporg( 'themeisle' ); $all_plugins = $this->get_plugins_from_wporg( 'themeisle' ); static $allowed_products = [ 'hestia' => true, 'neve' => true, 'visualizer' => true, 'feedzy-rss-feeds' => true, 'wp-product-review' => true, 'otter-blocks' => true, 'themeisle-companion' => true, ]; foreach ( $all_themes as $theme ) { if ( $theme->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $theme->slug ] ) ) { continue; } $products[] = array( 'name' => $theme->name, 'type' => 'theme', 'slug' => $theme->slug, 'installs' => $theme->active_installs, ); } foreach ( $all_plugins as $plugin ) { if ( $plugin->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $plugin->slug ] ) ) { continue; } $products[] = array( 'name' => $plugin->name, 'type' => 'plugin', 'slug' => $plugin->slug, 'installs' => $plugin->active_installs, ); } set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS ); } return $products; }
php
function get_product_from_api() { if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { $products = array(); $all_themes = $this->get_themes_from_wporg( 'themeisle' ); $all_plugins = $this->get_plugins_from_wporg( 'themeisle' ); static $allowed_products = [ 'hestia' => true, 'neve' => true, 'visualizer' => true, 'feedzy-rss-feeds' => true, 'wp-product-review' => true, 'otter-blocks' => true, 'themeisle-companion' => true, ]; foreach ( $all_themes as $theme ) { if ( $theme->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $theme->slug ] ) ) { continue; } $products[] = array( 'name' => $theme->name, 'type' => 'theme', 'slug' => $theme->slug, 'installs' => $theme->active_installs, ); } foreach ( $all_plugins as $plugin ) { if ( $plugin->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $plugin->slug ] ) ) { continue; } $products[] = array( 'name' => $plugin->name, 'type' => 'plugin', 'slug' => $plugin->slug, 'installs' => $plugin->active_installs, ); } set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS ); } return $products; }
[ "function", "get_product_from_api", "(", ")", "{", "if", "(", "false", "===", "(", "$", "products", "=", "get_transient", "(", "'themeisle_sdk_products'", ")", ")", ")", "{", "$", "products", "=", "array", "(", ")", ";", "$", "all_themes", "=", "$", "thi...
Fetch products from the recomended section. @return array|mixed The list of products to use in recomended section.
[ "Fetch", "products", "from", "the", "recomended", "section", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L375-L421
46,165
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.get_themes_from_wporg
function get_themes_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->themes ) ? $products->themes : array(); } else { $products = array(); } return (array) $products; }
php
function get_themes_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->themes ) ? $products->themes : array(); } else { $products = array(); } return (array) $products; }
[ "function", "get_themes_from_wporg", "(", "$", "author", ")", "{", "$", "products", "=", "wp_remote_get", "(", "'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]='", ".", "$", "author", ".", "'&request[per_page]=30&request[fields][active_installs]=true...
Fetch themes from wporg api. @param string $author The author name. @return array The list of themes.
[ "Fetch", "themes", "from", "wporg", "api", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L430-L442
46,166
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.get_plugins_from_wporg
function get_plugins_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->plugins ) ? $products->plugins : array(); } else { $products = array(); } return (array) $products; }
php
function get_plugins_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->plugins ) ? $products->plugins : array(); } else { $products = array(); } return (array) $products; }
[ "function", "get_plugins_from_wporg", "(", "$", "author", ")", "{", "$", "products", "=", "wp_remote_get", "(", "'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]='", ".", "$", "author", ".", "'&request[per_page]=40&request[fields][active_installs]=t...
Fetch plugin from wporg api. @param string $author The author slug. @return array The list of plugins for the selected author.
[ "Fetch", "plugin", "from", "wporg", "api", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L451-L463
46,167
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.load_resources
function load_resources() { add_thickbox(); $id = $this->product->get_key() . '_deactivate'; $this->add_css( $this->product->get_type(), $this->product->get_key() ); $this->add_js( $this->product->get_type(), $this->product->get_key(), '#TB_inline?' . apply_filters( $this->product->get_key() . '_feedback_deactivate_attributes', 'width=600&height=550' ) . '&inlineId=' . $id ); echo '<div id="' . $id . '" style="display:none;" class="themeisle-deactivate-box">' . $this->get_html( $this->product->get_type(), $this->product->get_key() ) . '</div>'; }
php
function load_resources() { add_thickbox(); $id = $this->product->get_key() . '_deactivate'; $this->add_css( $this->product->get_type(), $this->product->get_key() ); $this->add_js( $this->product->get_type(), $this->product->get_key(), '#TB_inline?' . apply_filters( $this->product->get_key() . '_feedback_deactivate_attributes', 'width=600&height=550' ) . '&inlineId=' . $id ); echo '<div id="' . $id . '" style="display:none;" class="themeisle-deactivate-box">' . $this->get_html( $this->product->get_type(), $this->product->get_key() ) . '</div>'; }
[ "function", "load_resources", "(", ")", "{", "add_thickbox", "(", ")", ";", "$", "id", "=", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_deactivate'", ";", "$", "this", "->", "add_css", "(", "$", "this", "->", "product", "->", "ge...
Loads the additional resources
[ "Loads", "the", "additional", "resources" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L129-L138
46,168
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.randomize_options
function randomize_options( $options ) { $new = array(); $keys = array_keys( $options ); shuffle( $keys ); foreach ( $keys as $key ) { $new[ $key ] = $options[ $key ]; } return $new; }
php
function randomize_options( $options ) { $new = array(); $keys = array_keys( $options ); shuffle( $keys ); foreach ( $keys as $key ) { $new[ $key ] = $options[ $key ]; } return $new; }
[ "function", "randomize_options", "(", "$", "options", ")", "{", "$", "new", "=", "array", "(", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "options", ")", ";", "shuffle", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", ...
Randomizes the options array. @param array $options The options array.
[ "Randomizes", "the", "options", "array", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L604-L614
46,169
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.post_deactivate
function post_deactivate() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $this->post_deactivate_or_cancel(); if ( empty( $_POST['id'] ) ) { wp_send_json( [] ); return; } $this->call_api( array( 'type' => 'deactivate', 'id' => $_POST['id'], 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', ) ); wp_send_json( [] ); }
php
function post_deactivate() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $this->post_deactivate_or_cancel(); if ( empty( $_POST['id'] ) ) { wp_send_json( [] ); return; } $this->call_api( array( 'type' => 'deactivate', 'id' => $_POST['id'], 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', ) ); wp_send_json( [] ); }
[ "function", "post_deactivate", "(", ")", "{", "check_ajax_referer", "(", "(", "string", ")", "__CLASS__", ",", "'nonce'", ")", ";", "$", "this", "->", "post_deactivate_or_cancel", "(", ")", ";", "if", "(", "empty", "(", "$", "_POST", "[", "'id'", "]", ")...
Called when the deactivate button is clicked.
[ "Called", "when", "the", "deactivate", "button", "is", "clicked", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L619-L639
46,170
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) { return false; } if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return true; } global $pagenow; if ( ! isset( $pagenow ) || empty( $pagenow ) ) { return false; } if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) { return false; } if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) { return false; } if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return true; } global $pagenow; if ( ! isset( $pagenow ) || empty( $pagenow ) ) { return false; } if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) { return false; } if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "product", "->", "is_theme", "(", ")", "&&", "(", "fa...
Should we load this object?. @param Product $product Product object. @return bool Should we load the module?
[ "Should", "we", "load", "this", "object?", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L686-L712
46,171
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.load
public function load( $product ) { $this->product = $product; add_action( 'admin_head', array( $this, 'load_resources' ) ); add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) ); return $this; }
php
public function load( $product ) { $this->product = $product; add_action( 'admin_head', array( $this, 'load_resources' ) ); add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) ); return $this; }
[ "public", "function", "load", "(", "$", "product", ")", "{", "$", "this", "->", "product", "=", "$", "product", ";", "add_action", "(", "'admin_head'", ",", "array", "(", "$", "this", ",", "'load_resources'", ")", ")", ";", "add_action", "(", "'wp_ajax_'...
Loads module hooks. @param Product $product Product details. @return Uninstall_Feedback Current module instance.
[ "Loads", "module", "hooks", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L721-L727
46,172
TypiCMS/Core
src/Commands/Create.php
Create.renameModelsAndRepositories
public function renameModelsAndRepositories() { $moduleDir = base_path('Modules/'.$this->module); $paths = [ $moduleDir.'/Models/Object.php', $moduleDir.'/Facades/Objects.php', $moduleDir.'/Repositories/EloquentObject.php', $moduleDir.'/resources/scss/public/_object.scss', $moduleDir.'/resources/scss/public/_object-list.scss', ]; foreach ($paths as $path) { $this->files->move($path, $this->transformFilename($path)); } }
php
public function renameModelsAndRepositories() { $moduleDir = base_path('Modules/'.$this->module); $paths = [ $moduleDir.'/Models/Object.php', $moduleDir.'/Facades/Objects.php', $moduleDir.'/Repositories/EloquentObject.php', $moduleDir.'/resources/scss/public/_object.scss', $moduleDir.'/resources/scss/public/_object-list.scss', ]; foreach ($paths as $path) { $this->files->move($path, $this->transformFilename($path)); } }
[ "public", "function", "renameModelsAndRepositories", "(", ")", "{", "$", "moduleDir", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ")", ";", "$", "paths", "=", "[", "$", "moduleDir", ".", "'/Models/Object.php'", ",", "$", "moduleDir...
Rename models and repositories.
[ "Rename", "models", "and", "repositories", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L139-L152
46,173
TypiCMS/Core
src/Commands/Create.php
Create.publishViews
public function publishViews() { $from = base_path('Modules/'.$this->module.'/resources/views'); $to = resource_path('views/vendor/'.strtolower($this->module)); $this->publishDirectory($from, $to); }
php
public function publishViews() { $from = base_path('Modules/'.$this->module.'/resources/views'); $to = resource_path('views/vendor/'.strtolower($this->module)); $this->publishDirectory($from, $to); }
[ "public", "function", "publishViews", "(", ")", "{", "$", "from", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ".", "'/resources/views'", ")", ";", "$", "to", "=", "resource_path", "(", "'views/vendor/'", ".", "strtolower", "(", "...
Publish views.
[ "Publish", "views", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L157-L162
46,174
TypiCMS/Core
src/Commands/Create.php
Create.publishScssFiles
public function publishScssFiles() { $from = base_path('Modules/'.$this->module.'/resources/scss/public'); $to = resource_path('scss/public'); $this->publishDirectory($from, $to); }
php
public function publishScssFiles() { $from = base_path('Modules/'.$this->module.'/resources/scss/public'); $to = resource_path('scss/public'); $this->publishDirectory($from, $to); }
[ "public", "function", "publishScssFiles", "(", ")", "{", "$", "from", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ".", "'/resources/scss/public'", ")", ";", "$", "to", "=", "resource_path", "(", "'scss/public'", ")", ";", "$", "t...
Publish scss files.
[ "Publish", "scss", "files", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L167-L172
46,175
TypiCMS/Core
src/Commands/Create.php
Create.moveMigrationFile
public function moveMigrationFile() { $from = base_path('Modules/'.$this->module.'/database/migrations/2016_01_04_225000_create_objects_table.php'); $to = base_path('database/migrations/'.date('Y_m_d_His').'_create_'.strtolower($this->module).'_table.php'); $this->files->move($from, $to); }
php
public function moveMigrationFile() { $from = base_path('Modules/'.$this->module.'/database/migrations/2016_01_04_225000_create_objects_table.php'); $to = base_path('database/migrations/'.date('Y_m_d_His').'_create_'.strtolower($this->module).'_table.php'); $this->files->move($from, $to); }
[ "public", "function", "moveMigrationFile", "(", ")", "{", "$", "from", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ".", "'/database/migrations/2016_01_04_225000_create_objects_table.php'", ")", ";", "$", "to", "=", "base_path", "(", "'da...
Rename and move migration file.
[ "Rename", "and", "move", "migration", "file", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L177-L182
46,176
TypiCMS/Core
src/Commands/Create.php
Create.transformFilename
public function transformFilename($path) { $pathTransformed = str_replace('object', strtolower(Str::singular($this->module)), $path); $pathTransformed = str_replace('Object', Str::singular($this->module), $pathTransformed); return $pathTransformed; }
php
public function transformFilename($path) { $pathTransformed = str_replace('object', strtolower(Str::singular($this->module)), $path); $pathTransformed = str_replace('Object', Str::singular($this->module), $pathTransformed); return $pathTransformed; }
[ "public", "function", "transformFilename", "(", "$", "path", ")", "{", "$", "pathTransformed", "=", "str_replace", "(", "'object'", ",", "strtolower", "(", "Str", "::", "singular", "(", "$", "this", "->", "module", ")", ")", ",", "$", "path", ")", ";", ...
Rename file in path. @param string $path @return string
[ "Rename", "file", "in", "path", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L209-L215
46,177
TypiCMS/Core
src/Commands/Create.php
Create.moduleExists
public function moduleExists() { $location1 = $this->files->isDirectory(base_path('Modules/'.$this->module)); $location2 = $this->files->isDirectory(base_path('vendor/typicms/'.strtolower($this->module))); return $location1 || $location2; }
php
public function moduleExists() { $location1 = $this->files->isDirectory(base_path('Modules/'.$this->module)); $location2 = $this->files->isDirectory(base_path('vendor/typicms/'.strtolower($this->module))); return $location1 || $location2; }
[ "public", "function", "moduleExists", "(", ")", "{", "$", "location1", "=", "$", "this", "->", "files", "->", "isDirectory", "(", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ")", ")", ";", "$", "location2", "=", "$", "this", "->",...
Check if the module exists. @return bool
[ "Check", "if", "the", "module", "exists", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L277-L283
46,178
TypiCMS/Core
src/Commands/Database.php
Database.getKeyFile
protected function getKeyFile() { return $this->files->exists('.env') ? $this->files->get('.env') : $this->files->get('.env.example'); }
php
protected function getKeyFile() { return $this->files->exists('.env') ? $this->files->get('.env') : $this->files->get('.env.example'); }
[ "protected", "function", "getKeyFile", "(", ")", "{", "return", "$", "this", "->", "files", "->", "exists", "(", "'.env'", ")", "?", "$", "this", "->", "files", "->", "get", "(", "'.env'", ")", ":", "$", "this", "->", "files", "->", "get", "(", "'....
Get the key file and return its content. @return string
[ "Get", "the", "key", "file", "and", "return", "its", "content", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Database.php#L140-L143
46,179
TypiCMS/Core
src/Http/Controllers/BaseAdminController.php
BaseAdminController.redirect
protected function redirect($request, $model) { if (is_array($model)) { $model = end($model); } $redirectUrl = $request->get('exit') ? $model->indexUrl() : $model->editUrl(); return redirect($redirectUrl); }
php
protected function redirect($request, $model) { if (is_array($model)) { $model = end($model); } $redirectUrl = $request->get('exit') ? $model->indexUrl() : $model->editUrl(); return redirect($redirectUrl); }
[ "protected", "function", "redirect", "(", "$", "request", ",", "$", "model", ")", "{", "if", "(", "is_array", "(", "$", "model", ")", ")", "{", "$", "model", "=", "end", "(", "$", "model", ")", ";", "}", "$", "redirectUrl", "=", "$", "request", "...
Redirect after a form is saved. @param $request @param $model @return \Illuminate\Http\RedirectResponse
[ "Redirect", "after", "a", "form", "is", "saved", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Http/Controllers/BaseAdminController.php#L25-L33
46,180
TypiCMS/Core
src/Models/Base.php
Base.scopePublished
public function scopePublished(Builder $query) { $field = 'status'; if (in_array($field, (array) $this->translatable)) { $field .= '->'.config('app.locale'); } return $query->where($field, '1'); }
php
public function scopePublished(Builder $query) { $field = 'status'; if (in_array($field, (array) $this->translatable)) { $field .= '->'.config('app.locale'); } return $query->where($field, '1'); }
[ "public", "function", "scopePublished", "(", "Builder", "$", "query", ")", "{", "$", "field", "=", "'status'", ";", "if", "(", "in_array", "(", "$", "field", ",", "(", "array", ")", "$", "this", "->", "translatable", ")", ")", "{", "$", "field", ".="...
Get published models. @param Builder $query @return Builder $query
[ "Get", "published", "models", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Models/Base.php#L51-L59
46,181
TypiCMS/Core
src/Models/Base.php
Base.scopeOrder
public function scopeOrder(Builder $query) { if ($order = config('typicms.'.$this->getTable().'.order')) { foreach ($order as $column => $direction) { $query->orderBy($column, $direction); } } return $query; }
php
public function scopeOrder(Builder $query) { if ($order = config('typicms.'.$this->getTable().'.order')) { foreach ($order as $column => $direction) { $query->orderBy($column, $direction); } } return $query; }
[ "public", "function", "scopeOrder", "(", "Builder", "$", "query", ")", "{", "if", "(", "$", "order", "=", "config", "(", "'typicms.'", ".", "$", "this", "->", "getTable", "(", ")", ".", "'.order'", ")", ")", "{", "foreach", "(", "$", "order", "as", ...
Order items. @param Builder $query @return Builder $query
[ "Order", "items", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Models/Base.php#L68-L77
46,182
TypiCMS/Core
src/Observers/FileObserver.php
FileObserver.deleted
public function deleted(Model $model) { try { Croppa::delete('storage/'.$model->getOriginal('path')); } catch (Exception $e) { Log::error($e->getMessage()); } }
php
public function deleted(Model $model) { try { Croppa::delete('storage/'.$model->getOriginal('path')); } catch (Exception $e) { Log::error($e->getMessage()); } }
[ "public", "function", "deleted", "(", "Model", "$", "model", ")", "{", "try", "{", "Croppa", "::", "delete", "(", "'storage/'", ".", "$", "model", "->", "getOriginal", "(", "'path'", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", ...
On delete, unlink files and thumbs. @param Model $model eloquent @return mixed false or void
[ "On", "delete", "unlink", "files", "and", "thumbs", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Observers/FileObserver.php#L28-L35
46,183
TypiCMS/Core
src/Observers/FileObserver.php
FileObserver.creating
public function creating(Model $model) { if (request()->hasFile('name')) { // delete prev image $file = $this->fileUploader->handle(request()->file('name')); $model->name = $file['filename']; $model->fill(Arr::except($file, 'filename')); } else { if ($model->type !== 'f') { return false; } } }
php
public function creating(Model $model) { if (request()->hasFile('name')) { // delete prev image $file = $this->fileUploader->handle(request()->file('name')); $model->name = $file['filename']; $model->fill(Arr::except($file, 'filename')); } else { if ($model->type !== 'f') { return false; } } }
[ "public", "function", "creating", "(", "Model", "$", "model", ")", "{", "if", "(", "request", "(", ")", "->", "hasFile", "(", "'name'", ")", ")", "{", "// delete prev image", "$", "file", "=", "$", "this", "->", "fileUploader", "->", "handle", "(", "re...
On save, upload files. @param Model $model eloquent @return mixed false or void
[ "On", "save", "upload", "files", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Observers/FileObserver.php#L44-L56
46,184
TypiCMS/Core
src/Providers/ModuleProvider.php
ModuleProvider.registerModuleRoutes
private function registerModuleRoutes() { $this->app->singleton('typicms.routes', function (Application $app) { try { return $app->make('Pages')->with('files')->getForRoutes(); } catch (Exception $e) { return []; } }); }
php
private function registerModuleRoutes() { $this->app->singleton('typicms.routes', function (Application $app) { try { return $app->make('Pages')->with('files')->getForRoutes(); } catch (Exception $e) { return []; } }); }
[ "private", "function", "registerModuleRoutes", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'typicms.routes'", ",", "function", "(", "Application", "$", "app", ")", "{", "try", "{", "return", "$", "app", "->", "make", "(", "'Pages'", ...
Get routes from pages. @return array
[ "Get", "routes", "from", "pages", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Providers/ModuleProvider.php#L153-L162
46,185
TypiCMS/Core
src/Observers/SlugObserver.php
SlugObserver.slugExists
private function slugExists(Model $model, $locale) { $query = $model::where('slug->'.$locale, $model->getTranslation('slug', $locale)); if ($model->id) { $query->where('id', '!=', $model->id); } return (bool) $query->count(); }
php
private function slugExists(Model $model, $locale) { $query = $model::where('slug->'.$locale, $model->getTranslation('slug', $locale)); if ($model->id) { $query->where('id', '!=', $model->id); } return (bool) $query->count(); }
[ "private", "function", "slugExists", "(", "Model", "$", "model", ",", "$", "locale", ")", "{", "$", "query", "=", "$", "model", "::", "where", "(", "'slug->'", ".", "$", "locale", ",", "$", "model", "->", "getTranslation", "(", "'slug'", ",", "$", "l...
Search for item with same slug. @param mixed $model @return bool
[ "Search", "for", "item", "with", "same", "slug", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Observers/SlugObserver.php#L40-L48
46,186
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.enabledLocales
public function enabledLocales() { $locales = []; foreach (locales() as $locale) { if (config('typicms.'.$locale.'.status')) { $locales[] = $locale; } } return $locales; }
php
public function enabledLocales() { $locales = []; foreach (locales() as $locale) { if (config('typicms.'.$locale.'.status')) { $locales[] = $locale; } } return $locales; }
[ "public", "function", "enabledLocales", "(", ")", "{", "$", "locales", "=", "[", "]", ";", "foreach", "(", "locales", "(", ")", "as", "$", "locale", ")", "{", "if", "(", "config", "(", "'typicms.'", ".", "$", "locale", ".", "'.status'", ")", ")", "...
Return enabled public locales. @return array
[ "Return", "enabled", "public", "locales", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L31-L41
46,187
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.permissions
public function permissions() { $permissions = []; foreach (config('typicms.permissions') as $module => $perms) { $key = __(ucfirst($module)); $permissions[$key] = $perms; } ksort($permissions, SORT_LOCALE_STRING); return $permissions; }
php
public function permissions() { $permissions = []; foreach (config('typicms.permissions') as $module => $perms) { $key = __(ucfirst($module)); $permissions[$key] = $perms; } ksort($permissions, SORT_LOCALE_STRING); return $permissions; }
[ "public", "function", "permissions", "(", ")", "{", "$", "permissions", "=", "[", "]", ";", "foreach", "(", "config", "(", "'typicms.permissions'", ")", "as", "$", "module", "=>", "$", "perms", ")", "{", "$", "key", "=", "__", "(", "ucfirst", "(", "$...
Get all permissions registered. @return array
[ "Get", "all", "permissions", "registered", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L90-L100
46,188
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.getPagesLinkedToModule
public function getPagesLinkedToModule($module = null) { $module = strtolower($module); $routes = app('typicms.routes'); $pages = []; foreach ($routes as $page) { if ($page->module == $module) { $pages[] = $page; } } return $pages; }
php
public function getPagesLinkedToModule($module = null) { $module = strtolower($module); $routes = app('typicms.routes'); $pages = []; foreach ($routes as $page) { if ($page->module == $module) { $pages[] = $page; } } return $pages; }
[ "public", "function", "getPagesLinkedToModule", "(", "$", "module", "=", "null", ")", "{", "$", "module", "=", "strtolower", "(", "$", "module", ")", ";", "$", "routes", "=", "app", "(", "'typicms.routes'", ")", ";", "$", "pages", "=", "[", "]", ";", ...
Return an array of pages linked to a module. @param string $module @return array
[ "Return", "an", "array", "of", "pages", "linked", "to", "a", "module", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L153-L166
46,189
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.templates
public function templates() { try { $directory = $this->getTemplateDir(); $files = File::files($directory); } catch (Exception $e) { $files = File::files(base_path('vendor/typicms/pages/src/resources/views/public')); } $templates = []; foreach ($files as $file) { $filename = File::name($file); if ($filename === 'default.blade') { continue; } $name = str_replace('.blade', '', $filename); if ($name[0] != '_' && $name != 'master') { $templates[$name] = ucfirst($name); } } return ['' => 'Default'] + $templates; }
php
public function templates() { try { $directory = $this->getTemplateDir(); $files = File::files($directory); } catch (Exception $e) { $files = File::files(base_path('vendor/typicms/pages/src/resources/views/public')); } $templates = []; foreach ($files as $file) { $filename = File::name($file); if ($filename === 'default.blade') { continue; } $name = str_replace('.blade', '', $filename); if ($name[0] != '_' && $name != 'master') { $templates[$name] = ucfirst($name); } } return ['' => 'Default'] + $templates; }
[ "public", "function", "templates", "(", ")", "{", "try", "{", "$", "directory", "=", "$", "this", "->", "getTemplateDir", "(", ")", ";", "$", "files", "=", "File", "::", "files", "(", "$", "directory", ")", ";", "}", "catch", "(", "Exception", "$", ...
List templates files from directory. @return array
[ "List", "templates", "files", "from", "directory", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L173-L194
46,190
TypiCMS/Core
src/Services/FileUploader.php
FileUploader.handle
public function handle(UploadedFile $file, $path = 'files') { $filesize = $file->getClientSize(); $mimetype = $file->getClientMimeType(); $extension = strtolower($file->getClientOriginalExtension()); $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)); $filename = $fileName.'.'.$extension; list($width, $height) = getimagesize($file); $filecounter = 1; while (Storage::has($path.'/'.$filename)) { $filename = $fileName.'_'.$filecounter++.'.'.$extension; } $path = $file->storeAs($path, $filename); $type = Arr::get(config('file.types'), $extension, 'd'); return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type'); }
php
public function handle(UploadedFile $file, $path = 'files') { $filesize = $file->getClientSize(); $mimetype = $file->getClientMimeType(); $extension = strtolower($file->getClientOriginalExtension()); $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)); $filename = $fileName.'.'.$extension; list($width, $height) = getimagesize($file); $filecounter = 1; while (Storage::has($path.'/'.$filename)) { $filename = $fileName.'_'.$filecounter++.'.'.$extension; } $path = $file->storeAs($path, $filename); $type = Arr::get(config('file.types'), $extension, 'd'); return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type'); }
[ "public", "function", "handle", "(", "UploadedFile", "$", "file", ",", "$", "path", "=", "'files'", ")", "{", "$", "filesize", "=", "$", "file", "->", "getClientSize", "(", ")", ";", "$", "mimetype", "=", "$", "file", "->", "getClientMimeType", "(", ")...
Handle the file upload. Returns the array on success, or false on failure. @param \Symfony\Component\HttpFoundation\File\UploadedFile $file @param string $path where to upload file @return array|bool
[ "Handle", "the", "file", "upload", ".", "Returns", "the", "array", "on", "success", "or", "false", "on", "failure", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/FileUploader.php#L21-L38
46,191
TypiCMS/Core
src/Http/Controllers/LocaleController.php
LocaleController.setContentLocale
public function setContentLocale($locale) { Session::put('allLocalesInForm', false); if ($locale === 'all') { Session::put('allLocalesInForm', true); } else { Session::put('locale', $locale); } }
php
public function setContentLocale($locale) { Session::put('allLocalesInForm', false); if ($locale === 'all') { Session::put('allLocalesInForm', true); } else { Session::put('locale', $locale); } }
[ "public", "function", "setContentLocale", "(", "$", "locale", ")", "{", "Session", "::", "put", "(", "'allLocalesInForm'", ",", "false", ")", ";", "if", "(", "$", "locale", "===", "'all'", ")", "{", "Session", "::", "put", "(", "'allLocalesInForm'", ",", ...
Change content locale. @return null
[ "Change", "content", "locale", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Http/Controllers/LocaleController.php#L14-L22
46,192
TypiCMS/Core
src/Services/Dates.php
Dates.concat
public static function concat($startingDate, $endingDate) { $startingDateArray = explode('-', $startingDate); $endingDateArray = explode('-', $endingDate); $endingDateFormat = '%A %d %B %Y'; if ($startingDate == $endingDate) { $startingDateFormat = '%A %d %B %Y'; return Carbon::createFromFormat('Y-m-d', $startingDate)->formatLocalized($startingDateFormat); } if ($startingDateArray[1] == $endingDateArray[1]) { // mois égaux $startingDateFormat = '%A %d'; } elseif ($startingDateArray[0] == $endingDateArray[0]) { // annee égales $startingDateFormat = '%A %d %B'; } else { $startingDateFormat = '%A %d %B %Y'; } return Carbon::createFromFormat('Y-m-d', $startingDate) ->formatLocalized($startingDateFormat).' to '.Carbon::createFromFormat('Y-m-d', $endingDate) ->formatLocalized($endingDateFormat); }
php
public static function concat($startingDate, $endingDate) { $startingDateArray = explode('-', $startingDate); $endingDateArray = explode('-', $endingDate); $endingDateFormat = '%A %d %B %Y'; if ($startingDate == $endingDate) { $startingDateFormat = '%A %d %B %Y'; return Carbon::createFromFormat('Y-m-d', $startingDate)->formatLocalized($startingDateFormat); } if ($startingDateArray[1] == $endingDateArray[1]) { // mois égaux $startingDateFormat = '%A %d'; } elseif ($startingDateArray[0] == $endingDateArray[0]) { // annee égales $startingDateFormat = '%A %d %B'; } else { $startingDateFormat = '%A %d %B %Y'; } return Carbon::createFromFormat('Y-m-d', $startingDate) ->formatLocalized($startingDateFormat).' to '.Carbon::createFromFormat('Y-m-d', $endingDate) ->formatLocalized($endingDateFormat); }
[ "public", "static", "function", "concat", "(", "$", "startingDate", ",", "$", "endingDate", ")", "{", "$", "startingDateArray", "=", "explode", "(", "'-'", ",", "$", "startingDate", ")", ";", "$", "endingDateArray", "=", "explode", "(", "'-'", ",", "$", ...
Concat two dates. @param string $startingDate @param string $endingDate @return string
[ "Concat", "two", "dates", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/Dates.php#L17-L42
46,193
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.datetimeOrNow
public function datetimeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d\TH:i'); }
php
public function datetimeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d\TH:i'); }
[ "public", "function", "datetimeOrNow", "(", "$", "column", "=", "'date'", ")", "{", "$", "date", "=", "$", "this", "->", "entity", "->", "$", "column", "?", ":", "Carbon", "::", "now", "(", ")", ";", "return", "$", "date", "->", "format", "(", "'Y-...
Return resource's datetime or curent date and time if empty. @param string $column @return Carbon
[ "Return", "resource", "s", "datetime", "or", "curent", "date", "and", "time", "if", "empty", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L76-L81
46,194
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.dateOrNow
public function dateOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d'); }
php
public function dateOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d'); }
[ "public", "function", "dateOrNow", "(", "$", "column", "=", "'date'", ")", "{", "$", "date", "=", "$", "this", "->", "entity", "->", "$", "column", "?", ":", "Carbon", "::", "now", "(", ")", ";", "return", "$", "date", "->", "format", "(", "'Y-m-d'...
Return resource's date or curent date if empty. @param string $column @return Carbon
[ "Return", "resource", "s", "date", "or", "curent", "date", "if", "empty", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L90-L95
46,195
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.timeOrNow
public function timeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('H:i'); }
php
public function timeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('H:i'); }
[ "public", "function", "timeOrNow", "(", "$", "column", "=", "'date'", ")", "{", "$", "date", "=", "$", "this", "->", "entity", "->", "$", "column", "?", ":", "Carbon", "::", "now", "(", ")", ";", "return", "$", "date", "->", "format", "(", "'H:i'",...
Return resource's time or curent time if empty. @param string $column @return Carbon
[ "Return", "resource", "s", "time", "or", "curent", "time", "if", "empty", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L104-L109
46,196
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.getImageUrlOrDefault
protected function getImageUrlOrDefault() { $file = ''; if (is_object($this->entity->image)) { $file = $this->entity->image->path; } if (!Storage::exists($file)) { $file = $this->imgNotFound(); } return Storage::url($file); }
php
protected function getImageUrlOrDefault() { $file = ''; if (is_object($this->entity->image)) { $file = $this->entity->image->path; } if (!Storage::exists($file)) { $file = $this->imgNotFound(); } return Storage::url($file); }
[ "protected", "function", "getImageUrlOrDefault", "(", ")", "{", "$", "file", "=", "''", ";", "if", "(", "is_object", "(", "$", "this", "->", "entity", "->", "image", ")", ")", "{", "$", "file", "=", "$", "this", "->", "entity", "->", "image", "->", ...
Get the path of the first image linked to this model or the path to the default image. @return string path
[ "Get", "the", "path", "of", "the", "first", "image", "linked", "to", "this", "model", "or", "the", "path", "to", "the", "default", "image", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L141-L154
46,197
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.image
public function image($width = null, $height = null, array $options = []) { $url = $this->getImageUrlOrDefault(); if (pathinfo($url, PATHINFO_EXTENSION) === 'svg') { return $url; } return url(Croppa::url($url, $width, $height, $options)); }
php
public function image($width = null, $height = null, array $options = []) { $url = $this->getImageUrlOrDefault(); if (pathinfo($url, PATHINFO_EXTENSION) === 'svg') { return $url; } return url(Croppa::url($url, $width, $height, $options)); }
[ "public", "function", "image", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "getImageUrlOrDefault", "(", ")", ";", "if", "(", "pathinfo",...
Return src string of a resized or cropped image. @param int $width width of image, null for auto @param int $height height of image, null for auto @param array $options see Croppa doc for options (https://github.com/BKWLD/croppa) @return string
[ "Return", "src", "string", "of", "a", "resized", "or", "cropped", "image", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L165-L174
46,198
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.imgNotFound
public function imgNotFound() { $file = 'img-not-found.png'; if (!Storage::exists($file)) { Storage::put($file, File::get(public_path('img/'.$file))); } return $file; }
php
public function imgNotFound() { $file = 'img-not-found.png'; if (!Storage::exists($file)) { Storage::put($file, File::get(public_path('img/'.$file))); } return $file; }
[ "public", "function", "imgNotFound", "(", ")", "{", "$", "file", "=", "'img-not-found.png'", ";", "if", "(", "!", "Storage", "::", "exists", "(", "$", "file", ")", ")", "{", "Storage", "::", "put", "(", "$", "file", ",", "File", "::", "get", "(", "...
Get default image when not found. @return string
[ "Get", "default", "image", "when", "not", "found", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L181-L189
46,199
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.body
public function body() { $text = $this->entity->body; preg_match_all('/{!! ([a-z]+):([0-9]+) !!}/', $text, $matches, PREG_SET_ORDER); $patterns = []; $replacements = []; $lang = config('app.locale'); if (is_array($matches)) { foreach ($matches as $match) { $patterns[] = $match[0]; $module = $match[1]; $repository = app('TypiCMS\Modules\\'.ucfirst(Str::plural($module)).'\Repositories\Eloquent'.ucfirst($module)); $model = $repository->published()->find($match[2]); if (!$model) { continue; } if ($module == 'page') { $replacements[] = url($model->uri($lang)); } else { if (Route::has($lang.'::'.$module)) { $replacements[] = route($lang.'::'.$module, $model->slug); } else { $replacements[] = ''; } } } } return str_replace($patterns, $replacements, $text); }
php
public function body() { $text = $this->entity->body; preg_match_all('/{!! ([a-z]+):([0-9]+) !!}/', $text, $matches, PREG_SET_ORDER); $patterns = []; $replacements = []; $lang = config('app.locale'); if (is_array($matches)) { foreach ($matches as $match) { $patterns[] = $match[0]; $module = $match[1]; $repository = app('TypiCMS\Modules\\'.ucfirst(Str::plural($module)).'\Repositories\Eloquent'.ucfirst($module)); $model = $repository->published()->find($match[2]); if (!$model) { continue; } if ($module == 'page') { $replacements[] = url($model->uri($lang)); } else { if (Route::has($lang.'::'.$module)) { $replacements[] = route($lang.'::'.$module, $model->slug); } else { $replacements[] = ''; } } } } return str_replace($patterns, $replacements, $text); }
[ "public", "function", "body", "(", ")", "{", "$", "text", "=", "$", "this", "->", "entity", "->", "body", ";", "preg_match_all", "(", "'/{!! ([a-z]+):([0-9]+) !!}/'", ",", "$", "text", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "$", "patterns", ...
Return body content with dynamic links. @return string
[ "Return", "body", "content", "with", "dynamic", "links", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L196-L225