PHP code example of itmar / wpsetting-class-package

1. Go to this page and download the library: Download itmar/wpsetting-class-package library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

itmar / wpsetting-class-package example snippets


$sql = $wpdb->prepare("SHOW TABLES LIKE %s", $table_name);
$result = ItmarDbCache::get_var_cached($sql, 'table_exists_' . md5($table_name));

$sql = $wpdb->prepare("SELECT * FROM {$table} WHERE token = %s", $token);
$row = ItmarDbCache::get_row_cached($sql, 'row_token_' . md5($token));

$result = ItmarDbCache::update_and_clear_cache(
    $wpdb->users,
    ['user_pass' => $hashed_password],
    ['ID' => $user_id],
    ['%s'],
    ['%d'],
    ['user_cache_' . $user_id]
);

$result = ItmarDbCache::delete_and_clear_cache(
    $table,
    ['id' => $row['id']],
    ['%d'],
    ['row_token_' . md5($row['token'])]
);

ItmarDbCache::set_cache_group('my_plugin_group');

define('WP_POST_REVISIONS', 5); // 5個までリビジョンを保存

$args = array(
    'post_id' => $post_id,
    'status'  => 'approve',
    'orderby' => 'comment_date',
    'order'   => 'ASC'
);

$comments = get_comments($args);

array(
    'comment_ID'         => strval($comment->comment_ID),
    'comment_post_ID'    => strval($comment->comment_post_ID),
    'comment_author'     => $comment->comment_author,
    'comment_author_email' => $comment->comment_author_email,
    'comment_date'       => $comment->comment_date,
    'comment_date_gmt'   => $comment->comment_date_gmt,
    'comment_content'    => $comment->comment_content,
    'comment_karma'      => strval($comment->comment_karma),
    'comment_approved'   => strval($comment->comment_approved),
    'comment_type'       => $comment->comment_type,
    'comment_parent'     => strval($comment->comment_parent),
    'user_id'            => strval($comment->user_id),
    'meta'               => $meta_formatted // メタデータを "meta" に格納
);