__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Get data.
*
*
* @return array Localized data.
*/
function seedprod_lite_fetch_inline_help_data() {
return array(
'category_articles' => seedprod_lite_fetch_articles(),
);
}
// Action
add_action( 'seedprod_lite_fetch_help_docs', 'seedprod_lite_update_help_articles' );
/**
* Get docs from the cache.
*
* @since 1.6.3
*
* @return array Docs data.
*/
function seedprod_lite_fetch_articles() {
// Get cache file.
$upload_dir = wp_upload_dir();
$path = trailingslashit( $upload_dir['basedir'] ) . 'seedprod-help-docs/'; // target directory.
$cache_file = wp_normalize_path( trailingslashit( $path ) . 'articles.json' );
if ( is_file( $cache_file ) && is_readable( $cache_file ) ) {
$articles = json_decode( file_get_contents( $cache_file ), true ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
}
clearstatcache();
if ( empty( $articles ) ) {
// This code should only when there are no articles available.
// seedprod_lite_update_help_articles() should be triggered by schedule.
$articles = seedprod_lite_update_help_articles();
}
// Store in class private variable for further use.
$articles = ! empty( $articles ) ? $articles : array();
return $articles;
}
/**
* Update docs cache with actual data retrieved from the remote source.
*
* @since 1.6.3
*
* @return array|boolean Updated docs data. Or false on error.
*/
function seedprod_lite_update_help_articles() {
// Fetch categories.
$categories = seedprod_lite_fetch_categories();
$articles = array();
// Loop over categories.
if ( ! is_array( $categories ) ) {
$categories = array();
}
if ( ! empty( $categories ) ) {
// Loop over categories and get articles.
$categories_length = count( $categories );
for ( $i = 0; $i < $categories_length; $i++ ) {
$current_category = $categories[ $i ];
$request = wp_remote_get(
add_query_arg( 'ht-kb-category', $current_category['id'], 'https://www.seedprod.com/wp-json/wp/v2/ht-kb' ),
array()
);
if ( is_wp_error( $request ) ) {
return false;
}
$content = wp_remote_retrieve_body( $request );
// Attempt to decode the json data.
$fetched_articles = json_decode( $content, true );
$articles_array = array(
'category_details' => array(),
);
// If the data successfully decoded to array we caching the content.
if ( is_array( $fetched_articles ) ) {
$articles_array['category_details'] = array(
'id' => $current_category['id'],
'name' => $current_category['name'],
'slug' => $current_category['slug'],
'article_count' => $current_category['count'],
);
$fetched_articles_count = count( $fetched_articles );
$fetched_articles_cleaned = array();
// Process fetched articles.
for ( $a = 0; $a < $fetched_articles_count; $a++ ) {
array_push(
$fetched_articles_cleaned,
array(
'id' => $fetched_articles[ $a ]['id'],
'date' => $fetched_articles[ $a ]['date'],
'slug' => $fetched_articles[ $a ]['slug'],
'link' => $fetched_articles[ $a ]['link'],
'title' => $fetched_articles[ $a ]['title'],
)
);
}
// Set articles.
$articles_array['articles'] = $fetched_articles_cleaned;
// Push docs array to the main articles array.
array_push( $articles, $articles_array );
} else {
$fetched_articles = array();
}
}
} else {
$articles = array();
}
// Add content to file & cache.
if ( ! empty( $articles ) && is_array( $articles ) ) {
// Set up upload file.
$upload_dir = wp_upload_dir();
$path = trailingslashit( $upload_dir['basedir'] ) . 'seedprod-help-docs/'; // target directory.
$cache_file = wp_normalize_path( trailingslashit( $path ) . 'articles.json' );
// Add fresh contents to cache file.
if ( true === seedprod_lite_set_up_upload_dir( $path, $cache_file ) ) {
file_put_contents( $cache_file, wp_json_encode( $articles ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
}
}
return $articles;
}
/**
* Create articles upload directory & create index file.
*
* @param string $path
* @param string $cache_file
* @return boolean|string
*/
function seedprod_lite_set_up_upload_dir( $path, $cache_file ) {
try {
// Check if directory exists. Create if it doesn't.
if ( ! is_dir( $path ) ) {
wp_mkdir_p( dirname( $cache_file ) );
}
// Create index file.
$index_file = wp_normalize_path( trailingslashit( $path ) . 'index.html' );
// Create empty index.html.
if ( ! file_exists( $index_file ) ) {
file_put_contents( $index_file, '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
}
return true;
} catch( \Exception $ex ) {
return $ex->getMessage();
}
}
/**
* Get categories.
*
* @since 1.6.3
*
* @return array Categories data.
*/
function seedprod_lite_fetch_categories() {
// Fetch categories.
$request = wp_remote_get( 'https://www.seedprod.com/wp-json/wp/v2/ht-kb-category' );
if ( is_wp_error( $request ) ) {
return false;
}
$content = wp_remote_retrieve_body( $request );
// Attempt to decode the json data.
$categories = json_decode( $content, true );
// If the data successfully decoded to array we caching the content.
if ( ! is_array( $categories ) ) {
$categories = array();
}
return $categories;
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| backwards | Folder | 0750 |
|
|
| includes | Folder | 0750 |
|
|
| admin-bar-menu.php | File | 3.95 KB | 0640 |
|
| bootstrap.php | File | 20.46 KB | 0640 |
|
| class-seedprod-notifications.php | File | 9.63 KB | 0640 |
|
| class-seedprod-review.php | File | 5.97 KB | 0640 |
|
| cpt.php | File | 541 B | 0640 |
|
| edit_with_seedprod.php | File | 21.61 KB | 0640 |
|
| functions-addons.php | File | 17.87 KB | 0640 |
|
| functions-envira-gallaries.php | File | 799 B | 0640 |
|
| functions-inline-help.php | File | 5.3 KB | 0640 |
|
| functions-mypaykit.php | File | 1.97 KB | 0640 |
|
| functions-openai.php | File | 16.53 KB | 0640 |
|
| functions-rafflepress.php | File | 1.86 KB | 0640 |
|
| functions-seedprod-gallery.php | File | 7 B | 0640 |
|
| functions-utils.php | File | 260.2 KB | 0640 |
|
| functions-wpforms.php | File | 1.6 KB | 0640 |
|
| import-cross-site-functions.php | File | 3.2 KB | 0640 |
|
| license.php | File | 5.43 KB | 0640 |
|
| load_controller.php | File | 1.75 KB | 0640 |
|
| lpage.php | File | 35.04 KB | 0640 |
|
| nestednavmenu.php | File | 5.09 KB | 0640 |
|
| render-csp-mm.php | File | 9.8 KB | 0640 |
|
| render-dynamic-tags.php | File | 26.24 KB | 0640 |
|
| render-lp.php | File | 1.15 KB | 0640 |
|
| routes.php | File | 24.79 KB | 0640 |
|
| settings.php | File | 6.01 KB | 0640 |
|
| setup-wizard.php | File | 12.08 KB | 0640 |
|
| subscriber.php | File | 2.63 KB | 0640 |
|
| theme-templates.php | File | 39.43 KB | 0640 |
|
| wp-cli-functions.php | File | 22.46 KB | 0640 |
|