Plugin Directory

Changeset 3473969


Ignore:
Timestamp:
03/03/2026 08:20:05 PM (3 weeks ago)
Author:
kaggdesign
Message:

Update to version 2.2.0 from GitHub

Location:
kagg-fast-post-generator
Files:
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • kagg-fast-post-generator/tags/2.2.0/plugin.php

    r3291889 r3473969  
    1010 * Plugin Name:       KAGG Generator
    1111 * Plugin URI:        https://wordpress.org/plugins/kagg-fast-post-generator/
    12  * Description:       Generates posts/pages. Useful to generate millions of records in wp_posts table.
    13  * Version:           2.1.0
    14  * Requires at least: 5.3
    15  * Requires PHP:      7.2
     12 * Description:       Generates posts/pages. Useful to generate millions of records in the wp_posts table.
     13 * Version:           2.2.0
     14 * Requires at least: 6.0
     15 * Requires PHP:      7.4
    1616 * Author:            KAGG Design
    1717 * Author URI:        https://profiles.wordpress.org/kaggdesign/
     
    2929}
    3030
    31 if ( defined( 'KAGG_GENERATOR_VERSION' ) ) {
    32     return;
    33 }
    34 
    3531/**
    3632 * Plugin version.
    3733 */
    38 const KAGG_GENERATOR_VERSION = '2.1.0';
     34const KAGG_GENERATOR_VERSION = '2.2.0';
    3935
    4036/**
  • kagg-fast-post-generator/tags/2.2.0/readme.txt

    r3291889 r3473969  
    22Contributors: kaggdesign
    33Tags: generate posts, generate pages, development, bulk generate
    4 Requires at least: 5.3
    5 Tested up to: 6.8
    6 Stable tag: 2.1.0
    7 Requires PHP: 7.2
     4Requires at least: 6.0
     5Tested up to: 6.9
     6Stable tag: 2.2.0
     7Requires PHP: 7.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
    15 In WordPress development, sometimes it is needed to generate extensive databases with hundreds of thousands of posts/pages. Existing plugins can generate test content very slowly, with the usual rate of 1,000 posts per hour.
     15In WordPress development, sometimes it is necessary to generate extensive databases with hundreds of thousands of posts/pages. Existing plugins can generate test content very slowly, with the usual rate of 1,000 posts per hour.
    1616
    1717The Fast Post Generator plugin can generate millions of posts/pages in minutes, which is 20,000 times faster than similar plugins.
     
    2727== Installation ==
    2828
    29 1. Upload `kagg-fast-post-generator` folder to the `/wp-content/plugins/` directory.
     291. Upload the `kagg-fast-post-generator` folder to the `/wp-content/plugins/` directory.
    30302. Activate the plugin through the 'Plugins' menu in WordPress.
    3131
     
    4040== Changelog ==
    4141
     42= 2.2.0 =
     43* The minimum required PHP version is now 7.4.
     44* The minimum required WordPress version is now 6.0.
     45
    4246= 2.1.0 =
    4347* Fixed "Function _load_textdomain_just_in_time was called incorrectly" notice.
     
    4549
    4650= 2.0.1 =
    47 * Fixed error on deleting a temporary table.
     51* Fixed the error on deleting a temporary table.
    4852
    4953= 2.0.0 =
    5054* Dropped support for PHP 7.0. The minimum required PHP version is now 7.2.
    5155* Fixed kagg_generator_comment_max_nesting_level filter name.
    52 * Fixed inability to create a temporary table when it exists after previous operations.
     56* Fixed the inability to create a temporary table when it exists after previous operations.
    5357* Fixed deprecation errors with PHP 8.4.
    5458* Tested with WordPress 6.7.
     
    6165* Tested with WordPress 6.5.
    6266* Tested with PHP 8.3.
    63 * Fixed fatal error with WP 6.3+.
     67* Fixed a fatal error with WP 6.3+.
    6468* Fixed deprecation errors with PHP 8.
    6569
     
    7579* Fixed: Item generation time now is properly distributed within the default period.
    7680* Added comments from not logged-in users.
    77 * Added filter for item's initial time shift.
     81* Added filter for an item's initial time shift.
    7882* Added filter for comment's random posts count.
    7983* Added filter for comment's random IPs count.
     
    8488* Added filter for logged-in user's percentage.
    8589* Added filter for paragraphs in the post.
    86 * Added filter for words in title.
     90* Added filter for words in the title.
    8791
    8892= 1.6.0 =
    8993* Tested with WordPress 6.1.
    90 * Fixed fatal error with WP 6.1 and SHORTINIT.
     94* Fixed a fatal error with WP 6.1 and SHORTINIT.
    9195
    9296= 1.5.0 =
     
    9599= 1.4.0 =
    96100* Added generation of comments, with hierarchy.
    97 * Improved posts' generation, now with random date and author.
     101* Improved posts' generation, now with a random date and author.
    98102* Added generation of users.
    99103
     
    103107
    104108= 1.2.0 =
    105 * Added ability to work on Linux servers.
     109* Added the ability to work on Linux servers.
    106110
    107111= 1.1.0 =
    108 * Added writing of all post fields initially created by WP Core for a post.
     112* Added writing of all post-fields initially created by WP Core for a post.
    109113
    110114= 1.0.0 =
  • kagg-fast-post-generator/tags/2.2.0/src/php/AdminNotices.php

    r3214212 r3473969  
    1818     * @var array
    1919     */
    20     private $notices = [];
     20    private array $notices = [];
    2121
    2222    /**
     
    6363
    6464    /**
    65      * Whether the current admin screen allowed to show the notice.
     65     * Whether the current admin screen allowed showing the notice.
    6666     *
    6767     * @param array $notice Notice.
  • kagg-fast-post-generator/tags/2.2.0/src/php/Generator/Comment.php

    r3214212 r3473969  
    2222     * @var int
    2323     */
    24     protected $random_posts_count;
     24    protected int $random_posts_count;
    2525
    2626    /**
     
    2929     * @var int
    3030     */
    31     protected $random_ips_count;
     31    protected int $random_ips_count;
    3232
    3333    /**
     
    3636     * @var int
    3737     */
    38     protected $max_nesting_level;
     38    protected int $max_nesting_level;
    3939
    4040    /**
     
    4343     * @var int
    4444     */
    45     protected $nesting_percentage;
     45    protected int $nesting_percentage;
    4646
    4747    /**
     
    5050     * @var int
    5151     */
    52     protected $max_sentences;
     52    protected int $max_sentences;
    5353
    5454    /**
     
    5757     * @var string
    5858     */
    59     protected $item_type = 'comment';
    60 
    61     /**
    62      * Item DB table name without prefix.
     59    protected string $item_type = 'comment';
     60
     61    /**
     62     * Item DB table name without a prefix.
    6363     *
    6464     * @var string
    6565     */
    66     protected $table = 'comments';
     66    protected string $table = 'comments';
    6767
    6868    /**
     
    7171     * @var string
    7272     */
    73     protected $marker_field = 'comment_author_url';
     73    protected string $marker_field = 'comment_author_url';
    7474
    7575    /**
     
    7878     * @var Randomizer
    7979     */
    80     private $post_id_randomizer;
     80    private Randomizer $post_id_randomizer;
    8181
    8282    /**
     
    8585     * @var Randomizer
    8686     */
    87     private $user_randomizer;
     87    private Randomizer $user_randomizer;
    8888
    8989    /**
     
    9292     * @var Randomizer
    9393     */
    94     private $logged_out_user_randomizer;
     94    private Randomizer $logged_out_user_randomizer;
    9595
    9696    /**
     
    9999     * @var Randomizer
    100100     */
    101     private $ip_randomizer;
     101    private Randomizer $ip_randomizer;
    102102
    103103    /**
     
    106106     * @var int
    107107     */
    108     private $comment_ID;
     108    private int $comment_ID;
    109109
    110110    /**
     
    113113     * @var array
    114114     */
    115     private $post_comments_stub;
     115    private array $post_comments_stub;
    116116
    117117    /**
     
    164164        $gmt_date = $this->gmt_date( self::MYSQL_TIME_FORMAT, $now );
    165165
    166         // Here we have to list the fields in the same order as in wp_comments table.
     166        // Here we have to list the fields in the same order as in the wp_comments table.
    167167        // Otherwise, csv file won't be created properly.
    168168        $this->stub = [
     
    269269
    270270    /**
    271      * Add comment to post and return comment parent.
     271     * Add comment to the post and return comment parent.
    272272     *
    273273     * @param object $post Post.
  • kagg-fast-post-generator/tags/2.2.0/src/php/Generator/Generator.php

    r3214212 r3473969  
    88namespace KAGG\Generator\Generator;
    99
     10use JsonException;
    1011use KAGG\Generator\Settings;
    1112use RuntimeException;
     
    2627     * @var string
    2728     */
    28     private $local_infile_value;
     29    private string $local_infile_value;
    2930
    3031    /**
     
    3334     * @var bool
    3435     */
    35     private $use_local_infile;
    36 
    37     /**
    38      * Registered item types and theirs handler class names.
     36    private bool $use_local_infile;
     37
     38    /**
     39     * Registered item types and their handler class names.
    3940     *
    4041     * @var string[] Item handlers.
    4142     */
    42     private $registered_items;
     43    private array $registered_items;
    4344
    4445    /**
     
    4748     * @var Item $item_handler
    4849     */
    49     private $item_handler;
     50    private Item $item_handler;
    5051
    5152    /**
     
    5455     * @var bool
    5556     */
    56     private $download_sql;
     57    private bool $download_sql;
    5758
    5859    /**
     
    8182     *
    8283     * @return bool
    83      * @throws RuntimeException With error message.
     84     * @throws RuntimeException With an error message.
    8485     */
    8586    public function use_local_infile(): bool {
     
    112113        // phpcs:disable WordPress.Security.NonceVerification.Missing
    113114        $index = isset( $_POST['index'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['index'] ) ) : 0;
    114         $data  = json_decode(
    115             isset( $_POST['data'] ) ? sanitize_text_field( wp_unslash( $_POST['data'] ) ) : '',
    116             false
    117         );
     115        try {
     116            $data = json_decode(
     117                isset( $_POST['data'] )
     118                    ? sanitize_text_field( wp_unslash( $_POST['data'] ) )
     119                    : '',
     120                false,
     121                512,
     122                JSON_THROW_ON_ERROR
     123            );
     124        } catch ( JsonException $e ) {
     125            $data = [];
     126        }
    118127        // phpcs:enable WordPress.Security.NonceVerification.Missing
    119128
     
    203212        // Nonce is checked by check_ajax_referer() in run_checks().
    204213        // phpcs:disable WordPress.Security.NonceVerification.Missing
    205         $data = json_decode(
    206             isset( $_POST['data'] ) ? sanitize_text_field( wp_unslash( $_POST['data'] ) ) : '',
    207             false
    208         );
     214        try {
     215            $data = json_decode(
     216                isset( $_POST['data'] )
     217                ? sanitize_text_field( wp_unslash( $_POST['data'] ) )
     218                : '',
     219                false,
     220                512,
     221                JSON_THROW_ON_ERROR
     222            );
     223        } catch ( JsonException $e ) {
     224            $data = [];
     225        }
    209226        // phpcs:enable WordPress.Security.NonceVerification.Missing
    210227
     
    304321     *
    305322     * @return void
    306      * @throws RuntimeException With error message.
     323     * @throws RuntimeException With an error message.
    307324     */
    308325    private function generate_items( int $count, string $temp_filename ): void {
     
    381398     *
    382399     * @return void
    383      * @throws RuntimeException With error message.
     400     * @throws RuntimeException With an error message.
    384401     * @noinspection SqlInsertValues
    385402     * @noinspection SqlResolve
     
    416433     *
    417434     * @return void
    418      * @throws RuntimeException With error message.
     435     * @throws RuntimeException With an error message.
    419436     */
    420437    private function store_items( string $temp_filename ): void {
     
    454471
    455472    /**
    456      * Set local_infile variable to 'ON' if needed.
    457      *
    458      * @return void
    459      * @throws RuntimeException With error message.
     473     * Set the local_infile variable to 'ON' if needed.
     474     *
     475     * @return void
     476     * @throws RuntimeException With an error message.
    460477     */
    461478    private function set_local_infile(): void {
     
    489506
    490507    /**
    491      * Revert local variable if needed.
    492      *
    493      * @return void
    494      * @throws RuntimeException With error message.
     508     * Revert a local variable if needed.
     509     *
     510     * @return void
     511     * @throws RuntimeException With an error message.
    495512     */
    496513    private function revert_local_infile(): void {
  • kagg-fast-post-generator/tags/2.2.0/src/php/Generator/Item.php

    r3214212 r3473969  
    4545     * @var int
    4646     */
    47     protected $number;
     47    protected int $number;
    4848
    4949    /**
     
    5252     * @var int
    5353     */
    54     protected $index;
     54    protected int $index;
    5555
    5656    /**
     
    5959     * @var string
    6060     */
    61     protected $item_type;
    62 
    63     /**
    64      * Item DB table name without prefix.
     61    protected string $item_type = '';
     62
     63    /**
     64     * Item DB table name without a prefix.
    6565     *
    6666     * @var string
    6767     */
    68     protected $table = 'posts';
     68    protected string $table = 'posts';
    6969
    7070    /**
     
    7373     * @var string
    7474     */
    75     protected $marker_field = 'guid';
     75    protected string $marker_field = 'guid';
    7676
    7777    /**
     
    8080     * @var array
    8181     */
    82     protected $stub = [];
     82    protected array $stub = [];
    8383
    8484    /**
     
    8787     * @var int
    8888     */
    89     protected $initial_time_shift;
     89    protected int $initial_time_shift;
    9090
    9191    /**
     
    9494     * @var int
    9595     */
    96     protected $max_time_shift;
     96    protected int $max_time_shift;
    9797
    9898    /**
     
    142142
    143143    /**
    144      * Get table name.
     144     * Get a table name.
    145145     *
    146146     * @return string
     
    151151
    152152    /**
    153      * Get marker field name.
     153     * Get a marker field name.
    154154     *
    155155     * @return string
  • kagg-fast-post-generator/tags/2.2.0/src/php/Generator/Page.php

    r2741161 r3473969  
    1818     * @var string
    1919     */
    20     protected $item_type = 'page';
     20    protected string $item_type = 'page';
    2121}
  • kagg-fast-post-generator/tags/2.2.0/src/php/Generator/Post.php

    r3214212 r3473969  
    2323     * @var string
    2424     */
    25     protected $item_type = 'post';
     25    protected string $item_type = 'post';
    2626
    2727    /**
     
    3030     * @var int
    3131     */
    32     protected $paragraphs_in_post;
     32    protected int $paragraphs_in_post;
    3333
    3434    /**
     
    3737     * @var int
    3838     */
    39     protected $words_in_title;
     39    protected int $words_in_title;
    4040
    4141    /**
     
    4444     * @var Randomizer
    4545     */
    46     private $user_randomizer;
     46    private Randomizer $user_randomizer;
    4747
    4848    /**
     
    5151     * @var stdClass
    5252     */
    53     private $post_time_keeper;
     53    private stdClass $post_time_keeper;
    5454
    5555    /**
  • kagg-fast-post-generator/tags/2.2.0/src/php/Generator/User.php

    r3214212 r3473969  
    2323     * @var string
    2424     */
    25     protected $item_type = 'user';
     25    protected string $item_type = 'user';
    2626
    2727    /**
    28      * Item DB table name without prefix.
     28     * Item DB table name without a prefix.
    2929     *
    3030     * @var string
    3131     */
    32     protected $table = 'users';
     32    protected string $table = 'users';
    3333
    3434    /**
     
    3737     * @var string
    3838     */
    39     protected $marker_field = 'user_url';
     39    protected string $marker_field = 'user_url';
    4040
    4141    /**
     
    4444     * @var Randomizer
    4545     */
    46     private $username_randomizer;
     46    private Randomizer $username_randomizer;
    4747
    4848    /**
     
    5151     * @var stdClass
    5252     */
    53     private $user_time_keeper;
     53    private stdClass $user_time_keeper;
    5454
    5555    /**
     
    5858     * @var string
    5959     */
    60     private $password;
     60    private string $password;
    6161
    6262    /**
     
    151151
    152152    /**
    153      * Add random time shift to user registered date.
     153     * Add a random time shift to the user registered date.
    154154     *
    155155     * @param object $user User.
  • kagg-fast-post-generator/tags/2.2.0/src/php/Lorem.php

    r3214212 r3473969  
    2626     * @var string[]
    2727     */
    28     protected static $word_list = [
     28    protected static array $word_list = [
    2929        'alias',
    3030        'consequatur',
     
    283283     * @var string[]
    284284     */
    285     protected static $name_list = [
     285    protected static array $name_list = [
    286286        'Aaron',
    287287        'Abel',
     
    12141214
    12151215    /**
    1216      * Randomize number of elements.
     1216     * Randomize the number of elements.
    12171217     *
    12181218     * @param integer $nb_elements Number of elements.
     
    12801280    private static function text_array_to_string( string $type, array $text ): string {
    12811281        if ( 'word' === $type ) {
    1282             // Capitalize a first letter.
     1282            // Capitalize the first letter.
    12831283            $text[0] = strtoupper( $text[0] );
    12841284
    1285             // End the sentence with full stop.
     1285            // End the sentence with a full stop.
    12861286            $text[ count( $text ) - 1 ] .= '.';
    12871287        }
  • kagg-fast-post-generator/tags/2.2.0/src/php/Randomizer.php

    r3214212 r3473969  
    1818     * @var array
    1919     */
    20     private $keys = [];
     20    private array $keys = [];
    2121
    2222    /**
     
    2525     * @var array
    2626     */
    27     private $elements;
     27    private array $elements;
    2828
    2929    /**
     
    3232     * @var int
    3333     */
    34     private $count;
     34    private int $count;
    3535
    3636    /**
     
    3939     * @var int
    4040     */
    41     private $index = 0;
     41    private int $index = 0;
    4242
    4343    /**
  • kagg-fast-post-generator/tags/2.2.0/src/php/Settings.php

    r3214219 r3473969  
    8484     * @var Generator
    8585     */
    86     private $generator;
     86    private Generator $generator;
    8787
    8888    /**
     
    9191     * @var array
    9292     */
    93     private $form_fields;
     93    private array $form_fields;
    9494
    9595    /**
     
    9898     * @var array
    9999     */
    100     private $settings;
     100    private array $settings;
    101101
    102102    /**
     
    334334     * @noinspection HtmlUnknownAttribute
    335335     */
    336     public function field_callback( array $arguments ): void {
     336    public function field_callback( array $arguments ): void { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
    337337        $value = $this->get_option( $arguments['field_id'] );
    338338
     
    779779
    780780    /**
    781      * Initialise Settings.
     781     * Initialize Settings.
    782782     *
    783783     * Store all settings in a single database entry
     
    786786     */
    787787    private function init_settings(): void {
    788         $this->settings = get_option( self::OPTION_KEY, null );
     788        $settings = get_option( self::OPTION_KEY, null );
    789789
    790790        // If there are no settings defined, use defaults.
    791         if ( ! is_array( $this->settings ) ) {
    792             $form_fields    = $this->get_form_fields();
    793             $this->settings = array_merge(
    794                 array_fill_keys( array_keys( $form_fields ), '' ),
    795                 wp_list_pluck( $form_fields, 'default' )
    796             );
    797         }
     791        if ( is_array( $settings ) ) {
     792            $this->settings = $settings;
     793
     794            return;
     795        }
     796
     797        $form_fields    = $this->get_form_fields();
     798        $this->settings = array_merge(
     799            array_fill_keys( array_keys( $form_fields ), '' ),
     800            wp_list_pluck( $form_fields, 'default' )
     801        );
    798802    }
    799803
  • kagg-fast-post-generator/tags/2.2.0/vendor/autoload.php

    r3291889 r3473969  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15::getLoader();
     22return ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf::getLoader();
  • kagg-fast-post-generator/tags/2.2.0/vendor/composer/autoload_real.php

    r3291889 r3473969  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15
     5class ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
  • kagg-fast-post-generator/tags/2.2.0/vendor/composer/autoload_static.php

    r3291889 r3473969  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15
     7class ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf
    88{
    99    public static $prefixLengthsPsr4 = array (
    10         'K' => 
     10        'K' =>
    1111        array (
    1212            'KAGG\\Generator\\' => 15,
     
    1515
    1616    public static $prefixDirsPsr4 = array (
    17         'KAGG\\Generator\\' => 
     17        'KAGG\\Generator\\' =>
    1818        array (
    1919            0 => __DIR__ . '/../..' . '/src/php',
     
    4040    {
    4141        return \Closure::bind(function () use ($loader) {
    42             $loader->prefixLengthsPsr4 = ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::$prefixLengthsPsr4;
    43             $loader->prefixDirsPsr4 = ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::$prefixDirsPsr4;
    44             $loader->classMap = ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::$classMap;
     42            $loader->prefixLengthsPsr4 = ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::$prefixLengthsPsr4;
     43            $loader->prefixDirsPsr4 = ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::$prefixDirsPsr4;
     44            $loader->classMap = ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::$classMap;
    4545
    4646        }, null, ClassLoader::class);
  • kagg-fast-post-generator/tags/2.2.0/vendor/composer/installed.php

    r3291889 r3473969  
    22    'root' => array(
    33        'name' => 'kagg/generator',
    4         'pretty_version' => '2.1.0',
    5         'version' => '2.1.0.0',
    6         'reference' => '9040afcab5f404e731e90b9d6414e71db2fea4a7',
     4        'pretty_version' => '2.2.0',
     5        'version' => '2.2.0.0',
     6        'reference' => 'db945036cc58b5ee2aae731388732be7ae24867e',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'kagg/generator' => array(
    14             'pretty_version' => '2.1.0',
    15             'version' => '2.1.0.0',
    16             'reference' => '9040afcab5f404e731e90b9d6414e71db2fea4a7',
     14            'pretty_version' => '2.2.0',
     15            'version' => '2.2.0.0',
     16            'reference' => 'db945036cc58b5ee2aae731388732be7ae24867e',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • kagg-fast-post-generator/trunk/plugin.php

    r3291889 r3473969  
    1010 * Plugin Name:       KAGG Generator
    1111 * Plugin URI:        https://wordpress.org/plugins/kagg-fast-post-generator/
    12  * Description:       Generates posts/pages. Useful to generate millions of records in wp_posts table.
    13  * Version:           2.1.0
    14  * Requires at least: 5.3
    15  * Requires PHP:      7.2
     12 * Description:       Generates posts/pages. Useful to generate millions of records in the wp_posts table.
     13 * Version:           2.2.0
     14 * Requires at least: 6.0
     15 * Requires PHP:      7.4
    1616 * Author:            KAGG Design
    1717 * Author URI:        https://profiles.wordpress.org/kaggdesign/
     
    2929}
    3030
    31 if ( defined( 'KAGG_GENERATOR_VERSION' ) ) {
    32     return;
    33 }
    34 
    3531/**
    3632 * Plugin version.
    3733 */
    38 const KAGG_GENERATOR_VERSION = '2.1.0';
     34const KAGG_GENERATOR_VERSION = '2.2.0';
    3935
    4036/**
  • kagg-fast-post-generator/trunk/readme.txt

    r3291889 r3473969  
    22Contributors: kaggdesign
    33Tags: generate posts, generate pages, development, bulk generate
    4 Requires at least: 5.3
    5 Tested up to: 6.8
    6 Stable tag: 2.1.0
    7 Requires PHP: 7.2
     4Requires at least: 6.0
     5Tested up to: 6.9
     6Stable tag: 2.2.0
     7Requires PHP: 7.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
    15 In WordPress development, sometimes it is needed to generate extensive databases with hundreds of thousands of posts/pages. Existing plugins can generate test content very slowly, with the usual rate of 1,000 posts per hour.
     15In WordPress development, sometimes it is necessary to generate extensive databases with hundreds of thousands of posts/pages. Existing plugins can generate test content very slowly, with the usual rate of 1,000 posts per hour.
    1616
    1717The Fast Post Generator plugin can generate millions of posts/pages in minutes, which is 20,000 times faster than similar plugins.
     
    2727== Installation ==
    2828
    29 1. Upload `kagg-fast-post-generator` folder to the `/wp-content/plugins/` directory.
     291. Upload the `kagg-fast-post-generator` folder to the `/wp-content/plugins/` directory.
    30302. Activate the plugin through the 'Plugins' menu in WordPress.
    3131
     
    4040== Changelog ==
    4141
     42= 2.2.0 =
     43* The minimum required PHP version is now 7.4.
     44* The minimum required WordPress version is now 6.0.
     45
    4246= 2.1.0 =
    4347* Fixed "Function _load_textdomain_just_in_time was called incorrectly" notice.
     
    4549
    4650= 2.0.1 =
    47 * Fixed error on deleting a temporary table.
     51* Fixed the error on deleting a temporary table.
    4852
    4953= 2.0.0 =
    5054* Dropped support for PHP 7.0. The minimum required PHP version is now 7.2.
    5155* Fixed kagg_generator_comment_max_nesting_level filter name.
    52 * Fixed inability to create a temporary table when it exists after previous operations.
     56* Fixed the inability to create a temporary table when it exists after previous operations.
    5357* Fixed deprecation errors with PHP 8.4.
    5458* Tested with WordPress 6.7.
     
    6165* Tested with WordPress 6.5.
    6266* Tested with PHP 8.3.
    63 * Fixed fatal error with WP 6.3+.
     67* Fixed a fatal error with WP 6.3+.
    6468* Fixed deprecation errors with PHP 8.
    6569
     
    7579* Fixed: Item generation time now is properly distributed within the default period.
    7680* Added comments from not logged-in users.
    77 * Added filter for item's initial time shift.
     81* Added filter for an item's initial time shift.
    7882* Added filter for comment's random posts count.
    7983* Added filter for comment's random IPs count.
     
    8488* Added filter for logged-in user's percentage.
    8589* Added filter for paragraphs in the post.
    86 * Added filter for words in title.
     90* Added filter for words in the title.
    8791
    8892= 1.6.0 =
    8993* Tested with WordPress 6.1.
    90 * Fixed fatal error with WP 6.1 and SHORTINIT.
     94* Fixed a fatal error with WP 6.1 and SHORTINIT.
    9195
    9296= 1.5.0 =
     
    9599= 1.4.0 =
    96100* Added generation of comments, with hierarchy.
    97 * Improved posts' generation, now with random date and author.
     101* Improved posts' generation, now with a random date and author.
    98102* Added generation of users.
    99103
     
    103107
    104108= 1.2.0 =
    105 * Added ability to work on Linux servers.
     109* Added the ability to work on Linux servers.
    106110
    107111= 1.1.0 =
    108 * Added writing of all post fields initially created by WP Core for a post.
     112* Added writing of all post-fields initially created by WP Core for a post.
    109113
    110114= 1.0.0 =
  • kagg-fast-post-generator/trunk/src/php/AdminNotices.php

    r3214212 r3473969  
    1818     * @var array
    1919     */
    20     private $notices = [];
     20    private array $notices = [];
    2121
    2222    /**
     
    6363
    6464    /**
    65      * Whether the current admin screen allowed to show the notice.
     65     * Whether the current admin screen allowed showing the notice.
    6666     *
    6767     * @param array $notice Notice.
  • kagg-fast-post-generator/trunk/src/php/Generator/Comment.php

    r3214212 r3473969  
    2222     * @var int
    2323     */
    24     protected $random_posts_count;
     24    protected int $random_posts_count;
    2525
    2626    /**
     
    2929     * @var int
    3030     */
    31     protected $random_ips_count;
     31    protected int $random_ips_count;
    3232
    3333    /**
     
    3636     * @var int
    3737     */
    38     protected $max_nesting_level;
     38    protected int $max_nesting_level;
    3939
    4040    /**
     
    4343     * @var int
    4444     */
    45     protected $nesting_percentage;
     45    protected int $nesting_percentage;
    4646
    4747    /**
     
    5050     * @var int
    5151     */
    52     protected $max_sentences;
     52    protected int $max_sentences;
    5353
    5454    /**
     
    5757     * @var string
    5858     */
    59     protected $item_type = 'comment';
    60 
    61     /**
    62      * Item DB table name without prefix.
     59    protected string $item_type = 'comment';
     60
     61    /**
     62     * Item DB table name without a prefix.
    6363     *
    6464     * @var string
    6565     */
    66     protected $table = 'comments';
     66    protected string $table = 'comments';
    6767
    6868    /**
     
    7171     * @var string
    7272     */
    73     protected $marker_field = 'comment_author_url';
     73    protected string $marker_field = 'comment_author_url';
    7474
    7575    /**
     
    7878     * @var Randomizer
    7979     */
    80     private $post_id_randomizer;
     80    private Randomizer $post_id_randomizer;
    8181
    8282    /**
     
    8585     * @var Randomizer
    8686     */
    87     private $user_randomizer;
     87    private Randomizer $user_randomizer;
    8888
    8989    /**
     
    9292     * @var Randomizer
    9393     */
    94     private $logged_out_user_randomizer;
     94    private Randomizer $logged_out_user_randomizer;
    9595
    9696    /**
     
    9999     * @var Randomizer
    100100     */
    101     private $ip_randomizer;
     101    private Randomizer $ip_randomizer;
    102102
    103103    /**
     
    106106     * @var int
    107107     */
    108     private $comment_ID;
     108    private int $comment_ID;
    109109
    110110    /**
     
    113113     * @var array
    114114     */
    115     private $post_comments_stub;
     115    private array $post_comments_stub;
    116116
    117117    /**
     
    164164        $gmt_date = $this->gmt_date( self::MYSQL_TIME_FORMAT, $now );
    165165
    166         // Here we have to list the fields in the same order as in wp_comments table.
     166        // Here we have to list the fields in the same order as in the wp_comments table.
    167167        // Otherwise, csv file won't be created properly.
    168168        $this->stub = [
     
    269269
    270270    /**
    271      * Add comment to post and return comment parent.
     271     * Add comment to the post and return comment parent.
    272272     *
    273273     * @param object $post Post.
  • kagg-fast-post-generator/trunk/src/php/Generator/Generator.php

    r3214212 r3473969  
    88namespace KAGG\Generator\Generator;
    99
     10use JsonException;
    1011use KAGG\Generator\Settings;
    1112use RuntimeException;
     
    2627     * @var string
    2728     */
    28     private $local_infile_value;
     29    private string $local_infile_value;
    2930
    3031    /**
     
    3334     * @var bool
    3435     */
    35     private $use_local_infile;
    36 
    37     /**
    38      * Registered item types and theirs handler class names.
     36    private bool $use_local_infile;
     37
     38    /**
     39     * Registered item types and their handler class names.
    3940     *
    4041     * @var string[] Item handlers.
    4142     */
    42     private $registered_items;
     43    private array $registered_items;
    4344
    4445    /**
     
    4748     * @var Item $item_handler
    4849     */
    49     private $item_handler;
     50    private Item $item_handler;
    5051
    5152    /**
     
    5455     * @var bool
    5556     */
    56     private $download_sql;
     57    private bool $download_sql;
    5758
    5859    /**
     
    8182     *
    8283     * @return bool
    83      * @throws RuntimeException With error message.
     84     * @throws RuntimeException With an error message.
    8485     */
    8586    public function use_local_infile(): bool {
     
    112113        // phpcs:disable WordPress.Security.NonceVerification.Missing
    113114        $index = isset( $_POST['index'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['index'] ) ) : 0;
    114         $data  = json_decode(
    115             isset( $_POST['data'] ) ? sanitize_text_field( wp_unslash( $_POST['data'] ) ) : '',
    116             false
    117         );
     115        try {
     116            $data = json_decode(
     117                isset( $_POST['data'] )
     118                    ? sanitize_text_field( wp_unslash( $_POST['data'] ) )
     119                    : '',
     120                false,
     121                512,
     122                JSON_THROW_ON_ERROR
     123            );
     124        } catch ( JsonException $e ) {
     125            $data = [];
     126        }
    118127        // phpcs:enable WordPress.Security.NonceVerification.Missing
    119128
     
    203212        // Nonce is checked by check_ajax_referer() in run_checks().
    204213        // phpcs:disable WordPress.Security.NonceVerification.Missing
    205         $data = json_decode(
    206             isset( $_POST['data'] ) ? sanitize_text_field( wp_unslash( $_POST['data'] ) ) : '',
    207             false
    208         );
     214        try {
     215            $data = json_decode(
     216                isset( $_POST['data'] )
     217                ? sanitize_text_field( wp_unslash( $_POST['data'] ) )
     218                : '',
     219                false,
     220                512,
     221                JSON_THROW_ON_ERROR
     222            );
     223        } catch ( JsonException $e ) {
     224            $data = [];
     225        }
    209226        // phpcs:enable WordPress.Security.NonceVerification.Missing
    210227
     
    304321     *
    305322     * @return void
    306      * @throws RuntimeException With error message.
     323     * @throws RuntimeException With an error message.
    307324     */
    308325    private function generate_items( int $count, string $temp_filename ): void {
     
    381398     *
    382399     * @return void
    383      * @throws RuntimeException With error message.
     400     * @throws RuntimeException With an error message.
    384401     * @noinspection SqlInsertValues
    385402     * @noinspection SqlResolve
     
    416433     *
    417434     * @return void
    418      * @throws RuntimeException With error message.
     435     * @throws RuntimeException With an error message.
    419436     */
    420437    private function store_items( string $temp_filename ): void {
     
    454471
    455472    /**
    456      * Set local_infile variable to 'ON' if needed.
    457      *
    458      * @return void
    459      * @throws RuntimeException With error message.
     473     * Set the local_infile variable to 'ON' if needed.
     474     *
     475     * @return void
     476     * @throws RuntimeException With an error message.
    460477     */
    461478    private function set_local_infile(): void {
     
    489506
    490507    /**
    491      * Revert local variable if needed.
    492      *
    493      * @return void
    494      * @throws RuntimeException With error message.
     508     * Revert a local variable if needed.
     509     *
     510     * @return void
     511     * @throws RuntimeException With an error message.
    495512     */
    496513    private function revert_local_infile(): void {
  • kagg-fast-post-generator/trunk/src/php/Generator/Item.php

    r3214212 r3473969  
    4545     * @var int
    4646     */
    47     protected $number;
     47    protected int $number;
    4848
    4949    /**
     
    5252     * @var int
    5353     */
    54     protected $index;
     54    protected int $index;
    5555
    5656    /**
     
    5959     * @var string
    6060     */
    61     protected $item_type;
    62 
    63     /**
    64      * Item DB table name without prefix.
     61    protected string $item_type = '';
     62
     63    /**
     64     * Item DB table name without a prefix.
    6565     *
    6666     * @var string
    6767     */
    68     protected $table = 'posts';
     68    protected string $table = 'posts';
    6969
    7070    /**
     
    7373     * @var string
    7474     */
    75     protected $marker_field = 'guid';
     75    protected string $marker_field = 'guid';
    7676
    7777    /**
     
    8080     * @var array
    8181     */
    82     protected $stub = [];
     82    protected array $stub = [];
    8383
    8484    /**
     
    8787     * @var int
    8888     */
    89     protected $initial_time_shift;
     89    protected int $initial_time_shift;
    9090
    9191    /**
     
    9494     * @var int
    9595     */
    96     protected $max_time_shift;
     96    protected int $max_time_shift;
    9797
    9898    /**
     
    142142
    143143    /**
    144      * Get table name.
     144     * Get a table name.
    145145     *
    146146     * @return string
     
    151151
    152152    /**
    153      * Get marker field name.
     153     * Get a marker field name.
    154154     *
    155155     * @return string
  • kagg-fast-post-generator/trunk/src/php/Generator/Page.php

    r2741161 r3473969  
    1818     * @var string
    1919     */
    20     protected $item_type = 'page';
     20    protected string $item_type = 'page';
    2121}
  • kagg-fast-post-generator/trunk/src/php/Generator/Post.php

    r3214212 r3473969  
    2323     * @var string
    2424     */
    25     protected $item_type = 'post';
     25    protected string $item_type = 'post';
    2626
    2727    /**
     
    3030     * @var int
    3131     */
    32     protected $paragraphs_in_post;
     32    protected int $paragraphs_in_post;
    3333
    3434    /**
     
    3737     * @var int
    3838     */
    39     protected $words_in_title;
     39    protected int $words_in_title;
    4040
    4141    /**
     
    4444     * @var Randomizer
    4545     */
    46     private $user_randomizer;
     46    private Randomizer $user_randomizer;
    4747
    4848    /**
     
    5151     * @var stdClass
    5252     */
    53     private $post_time_keeper;
     53    private stdClass $post_time_keeper;
    5454
    5555    /**
  • kagg-fast-post-generator/trunk/src/php/Generator/User.php

    r3214212 r3473969  
    2323     * @var string
    2424     */
    25     protected $item_type = 'user';
     25    protected string $item_type = 'user';
    2626
    2727    /**
    28      * Item DB table name without prefix.
     28     * Item DB table name without a prefix.
    2929     *
    3030     * @var string
    3131     */
    32     protected $table = 'users';
     32    protected string $table = 'users';
    3333
    3434    /**
     
    3737     * @var string
    3838     */
    39     protected $marker_field = 'user_url';
     39    protected string $marker_field = 'user_url';
    4040
    4141    /**
     
    4444     * @var Randomizer
    4545     */
    46     private $username_randomizer;
     46    private Randomizer $username_randomizer;
    4747
    4848    /**
     
    5151     * @var stdClass
    5252     */
    53     private $user_time_keeper;
     53    private stdClass $user_time_keeper;
    5454
    5555    /**
     
    5858     * @var string
    5959     */
    60     private $password;
     60    private string $password;
    6161
    6262    /**
     
    151151
    152152    /**
    153      * Add random time shift to user registered date.
     153     * Add a random time shift to the user registered date.
    154154     *
    155155     * @param object $user User.
  • kagg-fast-post-generator/trunk/src/php/Lorem.php

    r3214212 r3473969  
    2626     * @var string[]
    2727     */
    28     protected static $word_list = [
     28    protected static array $word_list = [
    2929        'alias',
    3030        'consequatur',
     
    283283     * @var string[]
    284284     */
    285     protected static $name_list = [
     285    protected static array $name_list = [
    286286        'Aaron',
    287287        'Abel',
     
    12141214
    12151215    /**
    1216      * Randomize number of elements.
     1216     * Randomize the number of elements.
    12171217     *
    12181218     * @param integer $nb_elements Number of elements.
     
    12801280    private static function text_array_to_string( string $type, array $text ): string {
    12811281        if ( 'word' === $type ) {
    1282             // Capitalize a first letter.
     1282            // Capitalize the first letter.
    12831283            $text[0] = strtoupper( $text[0] );
    12841284
    1285             // End the sentence with full stop.
     1285            // End the sentence with a full stop.
    12861286            $text[ count( $text ) - 1 ] .= '.';
    12871287        }
  • kagg-fast-post-generator/trunk/src/php/Randomizer.php

    r3214212 r3473969  
    1818     * @var array
    1919     */
    20     private $keys = [];
     20    private array $keys = [];
    2121
    2222    /**
     
    2525     * @var array
    2626     */
    27     private $elements;
     27    private array $elements;
    2828
    2929    /**
     
    3232     * @var int
    3333     */
    34     private $count;
     34    private int $count;
    3535
    3636    /**
     
    3939     * @var int
    4040     */
    41     private $index = 0;
     41    private int $index = 0;
    4242
    4343    /**
  • kagg-fast-post-generator/trunk/src/php/Settings.php

    r3214219 r3473969  
    8484     * @var Generator
    8585     */
    86     private $generator;
     86    private Generator $generator;
    8787
    8888    /**
     
    9191     * @var array
    9292     */
    93     private $form_fields;
     93    private array $form_fields;
    9494
    9595    /**
     
    9898     * @var array
    9999     */
    100     private $settings;
     100    private array $settings;
    101101
    102102    /**
     
    334334     * @noinspection HtmlUnknownAttribute
    335335     */
    336     public function field_callback( array $arguments ): void {
     336    public function field_callback( array $arguments ): void { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
    337337        $value = $this->get_option( $arguments['field_id'] );
    338338
     
    779779
    780780    /**
    781      * Initialise Settings.
     781     * Initialize Settings.
    782782     *
    783783     * Store all settings in a single database entry
     
    786786     */
    787787    private function init_settings(): void {
    788         $this->settings = get_option( self::OPTION_KEY, null );
     788        $settings = get_option( self::OPTION_KEY, null );
    789789
    790790        // If there are no settings defined, use defaults.
    791         if ( ! is_array( $this->settings ) ) {
    792             $form_fields    = $this->get_form_fields();
    793             $this->settings = array_merge(
    794                 array_fill_keys( array_keys( $form_fields ), '' ),
    795                 wp_list_pluck( $form_fields, 'default' )
    796             );
    797         }
     791        if ( is_array( $settings ) ) {
     792            $this->settings = $settings;
     793
     794            return;
     795        }
     796
     797        $form_fields    = $this->get_form_fields();
     798        $this->settings = array_merge(
     799            array_fill_keys( array_keys( $form_fields ), '' ),
     800            wp_list_pluck( $form_fields, 'default' )
     801        );
    798802    }
    799803
  • kagg-fast-post-generator/trunk/vendor/autoload.php

    r3291889 r3473969  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15::getLoader();
     22return ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf::getLoader();
  • kagg-fast-post-generator/trunk/vendor/composer/autoload_real.php

    r3291889 r3473969  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15
     5class ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit1afda73372e93cf71d2b40fd22ce3a15', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit5355545a8d8b5ece071ad74d0a09c7cf', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
  • kagg-fast-post-generator/trunk/vendor/composer/autoload_static.php

    r3291889 r3473969  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15
     7class ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf
    88{
    99    public static $prefixLengthsPsr4 = array (
    10         'K' => 
     10        'K' =>
    1111        array (
    1212            'KAGG\\Generator\\' => 15,
     
    1515
    1616    public static $prefixDirsPsr4 = array (
    17         'KAGG\\Generator\\' => 
     17        'KAGG\\Generator\\' =>
    1818        array (
    1919            0 => __DIR__ . '/../..' . '/src/php',
     
    4040    {
    4141        return \Closure::bind(function () use ($loader) {
    42             $loader->prefixLengthsPsr4 = ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::$prefixLengthsPsr4;
    43             $loader->prefixDirsPsr4 = ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::$prefixDirsPsr4;
    44             $loader->classMap = ComposerStaticInit1afda73372e93cf71d2b40fd22ce3a15::$classMap;
     42            $loader->prefixLengthsPsr4 = ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::$prefixLengthsPsr4;
     43            $loader->prefixDirsPsr4 = ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::$prefixDirsPsr4;
     44            $loader->classMap = ComposerStaticInit5355545a8d8b5ece071ad74d0a09c7cf::$classMap;
    4545
    4646        }, null, ClassLoader::class);
  • kagg-fast-post-generator/trunk/vendor/composer/installed.php

    r3291889 r3473969  
    22    'root' => array(
    33        'name' => 'kagg/generator',
    4         'pretty_version' => '2.1.0',
    5         'version' => '2.1.0.0',
    6         'reference' => '9040afcab5f404e731e90b9d6414e71db2fea4a7',
     4        'pretty_version' => '2.2.0',
     5        'version' => '2.2.0.0',
     6        'reference' => 'db945036cc58b5ee2aae731388732be7ae24867e',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'kagg/generator' => array(
    14             'pretty_version' => '2.1.0',
    15             'version' => '2.1.0.0',
    16             'reference' => '9040afcab5f404e731e90b9d6414e71db2fea4a7',
     14            'pretty_version' => '2.2.0',
     15            'version' => '2.2.0.0',
     16            'reference' => 'db945036cc58b5ee2aae731388732be7ae24867e',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.