Plugin Directory

Changeset 2516947


Ignore:
Timestamp:
04/17/2021 08:48:02 PM (5 years ago)
Author:
felipeloureirosantos
Message:

Update to version 0.2.0 from GitHub

Location:
presets
Files:
10 added
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • presets/tags/0.2.0/presets.php

    r2513575 r2516947  
    22/**
    33 * Plugin Name:     Presets
    4  * Description:     The Presets plugin allows you to fill your WordPress with demo data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     4 * Description:     The Presets plugin allows you to fill your WordPress with specific predefined settings in just a few seconds.
    55 * Author:          Presets contributors
    66 * Author URI:      https://github.com/felipelousantos/wp-presets/graphs/contributors
    77 * Text Domain:     presets
    8  * Version:         0.1.0
     8 * Version:         0.2.0
    99 *
    1010 * @package Presets
    1111 */
    1212
     13
     14/**
     15 * Function outputs the plugin directory with the root file name.
     16 *
     17 */
     18function presets_plugin_filename() {
     19    return str_replace( plugin_dir_path( __DIR__ ), '', $dir = plugin_dir_path( __FILE__ ) ) . 'presets.php';
     20}
     21
    1322require_once plugin_dir_path( __FILE__ ) . 'src/cpt/presets.php';
    1423require_once plugin_dir_path( __FILE__ ) . 'src/taxonomy/presets-tags.php';
     24require_once plugin_dir_path( __FILE__ ) . 'src/settings/advanced-settings.php';
     25require_once plugin_dir_path( __FILE__ ) . 'src/settings/helpers.php';
    1526require_once plugin_dir_path( __FILE__ ) . 'src/metabox/presets-options.php';
    1627require_once plugin_dir_path( __FILE__ ) . 'src/triggers/triggers.php';
  • presets/tags/0.2.0/readme.md

    r2513575 r2516947  
    1 Presets is a WordPress plugin that allows you to fill your WordPress with previously defined demo/test data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     1The Presets plugin allows you to fill your WordPress with previously defined settings in just a few seconds allowing you to test it without the need to manually change the settings every time.
     2
     3Currently, you are able to change WordPress user meta details and define plugins to be activated/deactivate when a preset is triggered, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
    24
    35This plugin hasn't been developed to be working on production sites. The goal with it is mostly to allow you to test plugins that require you to change the settings all the time.
    4 
    5 Currently, you are only able to change WordPress user meta details, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
  • presets/tags/0.2.0/readme.txt

    r2513575 r2516947  
    55Tested up to: 5.7
    66Requires PHP: 7.0
    7 Stable tag: 0.1.0
     7Stable tag: 0.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 The Presets plugin allows you to fill your WordPress with demo data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     11The Presets plugin allows you to fill your WordPress with specific predefined settings in just a few seconds.
    1212
    1313== Description ==
    1414
    15 The Presets plugin allows you to fill your WordPress with previously defined demo/test data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     15The Presets plugin allows you to fill your WordPress with previously defined settings in just a few seconds allowing you to test it without the need to manually change the settings every time.
     16
     17Currently, you are able to change WordPress user meta details and define plugins to be activated/deactivate when a preset is triggered, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
    1618
    1719This plugin hasn't been developed to be working on production sites. The goal with it is mostly to allow you to test plugins that require you to change the settings all the time.
    18 
    19 Currently, you are only able to change WordPress user meta details, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
    2020
    2121== Installation ==
     
    2929
    3030That plugin is not for production sites. it means that it won't probably make sense if you want to use it on your live site. It was created mostly with support teams and maybe even developers in mind that need to test things quickly and changing specific settings is required for that.
     31
    3132== Changelog ==
     33
     34= 0.2.0 =
     35Added the Plugins Module allowing you to activate/deactivate plugins when the preset is triggered.
    3236
    3337= 0.1.0 =
  • presets/tags/0.2.0/src/actions/apply-presets.php

    r2513575 r2516947  
    22
    33require_once plugin_dir_path( __FILE__ ) . 'core/user.php';
     4require_once plugin_dir_path( __FILE__ ) . 'core/plugins.php';
    45
    56function get_presets_meta( $prefix, $field ) {
    6     $selected_presets_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
    7     return get_post_meta( $selected_presets_id, 'presets_' . $prefix . $field, true );
    8 }
    9 
    10 function presets_admin_notice__success() {    ?>
    11     <div class="notice notice-success is-dismissible">
    12         <p><?php _e( 'The settings were applied as expected! ', 'presets' ); ?></p>
    13     </div>
    14     <?php
     7    $preset_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
     8    return get_post_meta( $preset_id, 'presets_' . $prefix . $field, true );
    159}
    1610
     
    2115    }
    2216
    23     $selected_presets_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
     17    $preset_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
    2418
    25     if ( get_post_type( $selected_presets_id ) !== 'presets' ) {
     19    if ( get_post_type( $preset_id ) !== 'presets' ) {
    2620        return;
    2721    }
    2822
    29     presets_core_user_apply_meta();
    30 
    31     add_action( 'admin_notices', 'presets_admin_notice__success' );
     23    /**
     24     * presets_apply_meta hook.
     25     *
     26     * @hooked presets_core_user_apply_meta
     27     * @hooked presets_core_plugins_apply_meta
     28     */
     29    do_action( 'presets_apply_meta' );
    3230
    3331}
    3432
    35 add_action( 'admin_head', 'apply_presets' );
     33add_action( 'admin_init', 'apply_presets', 10 );
     34
     35/**
     36 * Redirect after presets have been applied.
     37 */
     38function presets_apply_redirection() {
     39
     40    if ( ! isset( $_GET['presets-trigger'] ) || ! current_user_can( 'manage_options' ) ) {
     41        return;
     42    }
     43
     44    $preset_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
     45
     46    $redirect_url = add_query_arg( 'presets-applied', $preset_id, remove_query_arg( 'presets-trigger', $_SERVER['REQUEST_URI'] ) );
     47
     48    wp_safe_redirect( $redirect_url );
     49    exit;
     50
     51}
     52
     53add_action( 'admin_init', 'presets_apply_redirection', 20 );
     54
     55/**
     56 * Display notice after action confirmation.
     57 */
     58function presets_admin_notice__success() {
     59
     60    if ( ! isset( $_GET['presets-applied'] ) || ! current_user_can( 'manage_options' ) ) {
     61        return;
     62    }
     63
     64    ?>
     65        <div class="notice notice-success is-dismissible">
     66            <p><?php _e( 'The settings were applied as expected! ', 'presets' ); ?></p>
     67        </div>
     68    <?php
     69}
     70
     71add_action( 'admin_notices', 'presets_admin_notice__success' );
  • presets/tags/0.2.0/src/actions/core/user.php

    r2513575 r2516947  
    2727
    2828}
     29
     30add_action( 'presets_apply_meta', 'presets_core_user_apply_meta' );
  • presets/tags/0.2.0/src/metabox/core/user.php

    r2513575 r2516947  
    11<?php
    22
    3 $prefix_meta = $prefix . 'core_user_';
     3function presets_core_user_create_metabox() {
    44
    5 /**
    6  * Initiate the metabox
    7  */
    8 $cmb = new_cmb2_box(
    9     array(
    10         'id'           => $prefix_meta . 'metabox',
    11         'title'        => __( '[Core] Current user', 'presets' ),
    12         'object_types' => array( 'presets' ), // Post type
    13         'context'      => 'normal',
    14         'priority'     => 'high',
    15         'show_names'   => true, // Show field names on the left
    16     // 'cmb_styles' => false, // false to disable the CMB stylesheet
    17     // 'closed'     => true, // Keep the metabox closed by default
    18     )
    19 );
     5    $prefix_meta = 'presets_core_user_';
    206
    21 $cmb->add_field(
    22     array(
    23         'name' => __( 'First Name', 'presets' ),
    24         'id'   => $prefix_meta . 'first_name',
    25         'type' => 'text',
    26     )
    27 );
     7    /**
     8     * Initiate the metabox
     9     */
     10    $cmb = new_cmb2_box(
     11        array(
     12            'id'           => $prefix_meta . 'metabox',
     13            'title'        => __( '[Core] Current user', 'presets' ),
     14            'object_types' => array( 'presets' ), // Post type
     15            'context'      => 'normal',
     16            'priority'     => 'high',
     17            'show_names'   => true, // Show field names on the left
     18        // 'cmb_styles' => false, // false to disable the CMB stylesheet
     19        // 'closed'     => true, // Keep the metabox closed by default
     20        )
     21    );
    2822
    29 $cmb->add_field(
    30     array(
    31         'name' => __( 'Last Name', 'presets' ),
    32         'id'   => $prefix_meta . 'last_name',
    33         'type' => 'text',
    34     )
    35 );
     23    $cmb->add_field(
     24        array(
     25            'name' => __( 'First Name', 'presets' ),
     26            'id'   => $prefix_meta . 'first_name',
     27            'type' => 'text',
     28        )
     29    );
    3630
    37 $cmb->add_field(
    38     array(
    39         'name' => __( 'Display Name', 'presets' ),
    40         'id'   => $prefix_meta . 'display_name',
    41         'type' => 'text',
    42     )
    43 );
     31    $cmb->add_field(
     32        array(
     33            'name' => __( 'Last Name', 'presets' ),
     34            'id'   => $prefix_meta . 'last_name',
     35            'type' => 'text',
     36        )
     37    );
    4438
    45 $cmb->add_field(
    46     array(
    47         'name' => __( 'Website', 'presets' ),
    48         'id'   => $prefix_meta . 'user_url',
    49         'type' => 'text_url',
    50     )
    51 );
     39    $cmb->add_field(
     40        array(
     41            'name' => __( 'Display Name', 'presets' ),
     42            'id'   => $prefix_meta . 'display_name',
     43            'type' => 'text',
     44        )
     45    );
    5246
    53 $cmb->add_field(
    54     array(
    55         'name' => __( 'Email', 'presets' ),
    56         'id'   => $prefix_meta . 'user_email',
    57         'type' => 'text_email',
    58     )
    59 );
     47    $cmb->add_field(
     48        array(
     49            'name' => __( 'Website', 'presets' ),
     50            'id'   => $prefix_meta . 'user_url',
     51            'type' => 'text_url',
     52        )
     53    );
    6054
    61 $cmb->add_field(
    62     array(
    63         'name' => __( 'Bio', 'presets' ),
    64         'id'   => $prefix_meta . 'description',
    65         'type' => 'textarea',
    66     )
    67 );
     55    $cmb->add_field(
     56        array(
     57            'name' => __( 'Email', 'presets' ),
     58            'id'   => $prefix_meta . 'user_email',
     59            'type' => 'text_email',
     60        )
     61    );
     62
     63    $cmb->add_field(
     64        array(
     65            'name' => __( 'Bio', 'presets' ),
     66            'id'   => $prefix_meta . 'description',
     67            'type' => 'textarea',
     68        )
     69    );
     70
     71}
     72
     73add_action( 'presets_create_metabox', 'presets_core_user_create_metabox' );
  • presets/tags/0.2.0/src/metabox/presets-options.php

    r2513575 r2516947  
    22
    33/**
    4  * Adding 'cmb2' vendor
     4 * Adding 'cmb2' vendor.
    55 */
    66if ( file_exists( dirname( __FILE__ ) . '/../../vendors/cmb2/init.php' ) ) {
     
    88}
    99
     10
     11include_once plugin_dir_path( __FILE__ ) . 'core/user.php';
     12include_once plugin_dir_path( __FILE__ ) . 'core/plugins.php';
     13
     14/**
     15 * Create metabox.
     16 */
    1017function presets_options() {
    1118
    1219    $prefix = 'presets_';
    1320
    14     include_once plugin_dir_path( __FILE__ ) . 'core/user.php';
     21    /**
     22     * presets_create_metabox hook.
     23     *
     24     * @hooked presets_core_user_create_metabox
     25     * @hooked presets_core_plugins_create_metabox
     26     */
     27    do_action( 'presets_create_metabox' );
    1528
    1629}
  • presets/tags/0.2.0/src/triggers/triggers.php

    r2513575 r2516947  
    22
    33include_once plugin_dir_path( __FILE__ ) . 'wp-admin-bar/trigger.php';
     4
     5function presets_get_ids() {
     6
     7    return get_posts(
     8        array(
     9            'fields'         => 'ids',
     10            'posts_per_page' => -1,
     11            'post_type'      => 'presets',
     12        )
     13    );
     14
     15}
     16
     17function presets_get_current_url( $id ) {
     18
     19    return add_query_arg( 'presets-trigger', $id, $_SERVER['REQUEST_URI'] );
     20
     21}
  • presets/tags/0.2.0/src/triggers/wp-admin-bar/trigger.php

    r2513575 r2516947  
    66        return;
    77    }
     8
    89    $admin_bar->add_menu(
    910        array(
     
    1920    );
    2021
    21     $presets_ids = get_posts(
    22         array(
    23             'fields'         => 'ids',
    24             'posts_per_page' => -1,
    25             'post_type'      => 'presets',
    26         )
    27     );
    28 
    29     foreach ( $presets_ids as $id ) {
     22    foreach ( presets_get_ids() as $id ) {
    3023
    3124        $admin_bar->add_menu(
     
    3528                'group'  => null,
    3629                'title'  => get_the_title( $id ), // you can use img tag with image link. it will show the image icon Instead of the title.
    37                 'href'   => admin_url( 'edit.php?post_type=presets&presets-trigger=' . $id ),
     30                'href'   => presets_get_current_url( $id ),
    3831                'meta'   => array(
    3932                    'title' => get_the_title( $id ), // This title will show on hover.
     
    4639}
    4740
    48 add_action( 'admin_bar_menu', 'presets_admin_bar_item', 100 );
     41add_action(
     42    'admin_init',
     43    function () {
     44        add_action( 'admin_bar_menu', 'presets_admin_bar_item', 100 );
     45    }
     46);
  • presets/trunk/presets.php

    r2513575 r2516947  
    22/**
    33 * Plugin Name:     Presets
    4  * Description:     The Presets plugin allows you to fill your WordPress with demo data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     4 * Description:     The Presets plugin allows you to fill your WordPress with specific predefined settings in just a few seconds.
    55 * Author:          Presets contributors
    66 * Author URI:      https://github.com/felipelousantos/wp-presets/graphs/contributors
    77 * Text Domain:     presets
    8  * Version:         0.1.0
     8 * Version:         0.2.0
    99 *
    1010 * @package Presets
    1111 */
    1212
     13
     14/**
     15 * Function outputs the plugin directory with the root file name.
     16 *
     17 */
     18function presets_plugin_filename() {
     19    return str_replace( plugin_dir_path( __DIR__ ), '', $dir = plugin_dir_path( __FILE__ ) ) . 'presets.php';
     20}
     21
    1322require_once plugin_dir_path( __FILE__ ) . 'src/cpt/presets.php';
    1423require_once plugin_dir_path( __FILE__ ) . 'src/taxonomy/presets-tags.php';
     24require_once plugin_dir_path( __FILE__ ) . 'src/settings/advanced-settings.php';
     25require_once plugin_dir_path( __FILE__ ) . 'src/settings/helpers.php';
    1526require_once plugin_dir_path( __FILE__ ) . 'src/metabox/presets-options.php';
    1627require_once plugin_dir_path( __FILE__ ) . 'src/triggers/triggers.php';
  • presets/trunk/readme.md

    r2513575 r2516947  
    1 Presets is a WordPress plugin that allows you to fill your WordPress with previously defined demo/test data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     1The Presets plugin allows you to fill your WordPress with previously defined settings in just a few seconds allowing you to test it without the need to manually change the settings every time.
     2
     3Currently, you are able to change WordPress user meta details and define plugins to be activated/deactivate when a preset is triggered, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
    24
    35This plugin hasn't been developed to be working on production sites. The goal with it is mostly to allow you to test plugins that require you to change the settings all the time.
    4 
    5 Currently, you are only able to change WordPress user meta details, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
  • presets/trunk/readme.txt

    r2513575 r2516947  
    55Tested up to: 5.7
    66Requires PHP: 7.0
    7 Stable tag: 0.1.0
     7Stable tag: 0.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 The Presets plugin allows you to fill your WordPress with demo data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     11The Presets plugin allows you to fill your WordPress with specific predefined settings in just a few seconds.
    1212
    1313== Description ==
    1414
    15 The Presets plugin allows you to fill your WordPress with previously defined demo/test data in just a few seconds allowing you to test it without the need to manually change the settings every time.
     15The Presets plugin allows you to fill your WordPress with previously defined settings in just a few seconds allowing you to test it without the need to manually change the settings every time.
     16
     17Currently, you are able to change WordPress user meta details and define plugins to be activated/deactivate when a preset is triggered, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
    1618
    1719This plugin hasn't been developed to be working on production sites. The goal with it is mostly to allow you to test plugins that require you to change the settings all the time.
    18 
    19 Currently, you are only able to change WordPress user meta details, but the goal will be to bring more WordPress and WooCommerce settings. We hope to make it easy in the long term to extend and bring more plugins settings.
    2020
    2121== Installation ==
     
    2929
    3030That plugin is not for production sites. it means that it won't probably make sense if you want to use it on your live site. It was created mostly with support teams and maybe even developers in mind that need to test things quickly and changing specific settings is required for that.
     31
    3132== Changelog ==
     33
     34= 0.2.0 =
     35Added the Plugins Module allowing you to activate/deactivate plugins when the preset is triggered.
    3236
    3337= 0.1.0 =
  • presets/trunk/src/actions/apply-presets.php

    r2513575 r2516947  
    22
    33require_once plugin_dir_path( __FILE__ ) . 'core/user.php';
     4require_once plugin_dir_path( __FILE__ ) . 'core/plugins.php';
    45
    56function get_presets_meta( $prefix, $field ) {
    6     $selected_presets_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
    7     return get_post_meta( $selected_presets_id, 'presets_' . $prefix . $field, true );
    8 }
    9 
    10 function presets_admin_notice__success() {    ?>
    11     <div class="notice notice-success is-dismissible">
    12         <p><?php _e( 'The settings were applied as expected! ', 'presets' ); ?></p>
    13     </div>
    14     <?php
     7    $preset_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
     8    return get_post_meta( $preset_id, 'presets_' . $prefix . $field, true );
    159}
    1610
     
    2115    }
    2216
    23     $selected_presets_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
     17    $preset_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
    2418
    25     if ( get_post_type( $selected_presets_id ) !== 'presets' ) {
     19    if ( get_post_type( $preset_id ) !== 'presets' ) {
    2620        return;
    2721    }
    2822
    29     presets_core_user_apply_meta();
    30 
    31     add_action( 'admin_notices', 'presets_admin_notice__success' );
     23    /**
     24     * presets_apply_meta hook.
     25     *
     26     * @hooked presets_core_user_apply_meta
     27     * @hooked presets_core_plugins_apply_meta
     28     */
     29    do_action( 'presets_apply_meta' );
    3230
    3331}
    3432
    35 add_action( 'admin_head', 'apply_presets' );
     33add_action( 'admin_init', 'apply_presets', 10 );
     34
     35/**
     36 * Redirect after presets have been applied.
     37 */
     38function presets_apply_redirection() {
     39
     40    if ( ! isset( $_GET['presets-trigger'] ) || ! current_user_can( 'manage_options' ) ) {
     41        return;
     42    }
     43
     44    $preset_id = filter_var( $_GET['presets-trigger'], FILTER_SANITIZE_NUMBER_INT );
     45
     46    $redirect_url = add_query_arg( 'presets-applied', $preset_id, remove_query_arg( 'presets-trigger', $_SERVER['REQUEST_URI'] ) );
     47
     48    wp_safe_redirect( $redirect_url );
     49    exit;
     50
     51}
     52
     53add_action( 'admin_init', 'presets_apply_redirection', 20 );
     54
     55/**
     56 * Display notice after action confirmation.
     57 */
     58function presets_admin_notice__success() {
     59
     60    if ( ! isset( $_GET['presets-applied'] ) || ! current_user_can( 'manage_options' ) ) {
     61        return;
     62    }
     63
     64    ?>
     65        <div class="notice notice-success is-dismissible">
     66            <p><?php _e( 'The settings were applied as expected! ', 'presets' ); ?></p>
     67        </div>
     68    <?php
     69}
     70
     71add_action( 'admin_notices', 'presets_admin_notice__success' );
  • presets/trunk/src/actions/core/user.php

    r2513575 r2516947  
    2727
    2828}
     29
     30add_action( 'presets_apply_meta', 'presets_core_user_apply_meta' );
  • presets/trunk/src/metabox/core/user.php

    r2513575 r2516947  
    11<?php
    22
    3 $prefix_meta = $prefix . 'core_user_';
     3function presets_core_user_create_metabox() {
    44
    5 /**
    6  * Initiate the metabox
    7  */
    8 $cmb = new_cmb2_box(
    9     array(
    10         'id'           => $prefix_meta . 'metabox',
    11         'title'        => __( '[Core] Current user', 'presets' ),
    12         'object_types' => array( 'presets' ), // Post type
    13         'context'      => 'normal',
    14         'priority'     => 'high',
    15         'show_names'   => true, // Show field names on the left
    16     // 'cmb_styles' => false, // false to disable the CMB stylesheet
    17     // 'closed'     => true, // Keep the metabox closed by default
    18     )
    19 );
     5    $prefix_meta = 'presets_core_user_';
    206
    21 $cmb->add_field(
    22     array(
    23         'name' => __( 'First Name', 'presets' ),
    24         'id'   => $prefix_meta . 'first_name',
    25         'type' => 'text',
    26     )
    27 );
     7    /**
     8     * Initiate the metabox
     9     */
     10    $cmb = new_cmb2_box(
     11        array(
     12            'id'           => $prefix_meta . 'metabox',
     13            'title'        => __( '[Core] Current user', 'presets' ),
     14            'object_types' => array( 'presets' ), // Post type
     15            'context'      => 'normal',
     16            'priority'     => 'high',
     17            'show_names'   => true, // Show field names on the left
     18        // 'cmb_styles' => false, // false to disable the CMB stylesheet
     19        // 'closed'     => true, // Keep the metabox closed by default
     20        )
     21    );
    2822
    29 $cmb->add_field(
    30     array(
    31         'name' => __( 'Last Name', 'presets' ),
    32         'id'   => $prefix_meta . 'last_name',
    33         'type' => 'text',
    34     )
    35 );
     23    $cmb->add_field(
     24        array(
     25            'name' => __( 'First Name', 'presets' ),
     26            'id'   => $prefix_meta . 'first_name',
     27            'type' => 'text',
     28        )
     29    );
    3630
    37 $cmb->add_field(
    38     array(
    39         'name' => __( 'Display Name', 'presets' ),
    40         'id'   => $prefix_meta . 'display_name',
    41         'type' => 'text',
    42     )
    43 );
     31    $cmb->add_field(
     32        array(
     33            'name' => __( 'Last Name', 'presets' ),
     34            'id'   => $prefix_meta . 'last_name',
     35            'type' => 'text',
     36        )
     37    );
    4438
    45 $cmb->add_field(
    46     array(
    47         'name' => __( 'Website', 'presets' ),
    48         'id'   => $prefix_meta . 'user_url',
    49         'type' => 'text_url',
    50     )
    51 );
     39    $cmb->add_field(
     40        array(
     41            'name' => __( 'Display Name', 'presets' ),
     42            'id'   => $prefix_meta . 'display_name',
     43            'type' => 'text',
     44        )
     45    );
    5246
    53 $cmb->add_field(
    54     array(
    55         'name' => __( 'Email', 'presets' ),
    56         'id'   => $prefix_meta . 'user_email',
    57         'type' => 'text_email',
    58     )
    59 );
     47    $cmb->add_field(
     48        array(
     49            'name' => __( 'Website', 'presets' ),
     50            'id'   => $prefix_meta . 'user_url',
     51            'type' => 'text_url',
     52        )
     53    );
    6054
    61 $cmb->add_field(
    62     array(
    63         'name' => __( 'Bio', 'presets' ),
    64         'id'   => $prefix_meta . 'description',
    65         'type' => 'textarea',
    66     )
    67 );
     55    $cmb->add_field(
     56        array(
     57            'name' => __( 'Email', 'presets' ),
     58            'id'   => $prefix_meta . 'user_email',
     59            'type' => 'text_email',
     60        )
     61    );
     62
     63    $cmb->add_field(
     64        array(
     65            'name' => __( 'Bio', 'presets' ),
     66            'id'   => $prefix_meta . 'description',
     67            'type' => 'textarea',
     68        )
     69    );
     70
     71}
     72
     73add_action( 'presets_create_metabox', 'presets_core_user_create_metabox' );
  • presets/trunk/src/metabox/presets-options.php

    r2513575 r2516947  
    22
    33/**
    4  * Adding 'cmb2' vendor
     4 * Adding 'cmb2' vendor.
    55 */
    66if ( file_exists( dirname( __FILE__ ) . '/../../vendors/cmb2/init.php' ) ) {
     
    88}
    99
     10
     11include_once plugin_dir_path( __FILE__ ) . 'core/user.php';
     12include_once plugin_dir_path( __FILE__ ) . 'core/plugins.php';
     13
     14/**
     15 * Create metabox.
     16 */
    1017function presets_options() {
    1118
    1219    $prefix = 'presets_';
    1320
    14     include_once plugin_dir_path( __FILE__ ) . 'core/user.php';
     21    /**
     22     * presets_create_metabox hook.
     23     *
     24     * @hooked presets_core_user_create_metabox
     25     * @hooked presets_core_plugins_create_metabox
     26     */
     27    do_action( 'presets_create_metabox' );
    1528
    1629}
  • presets/trunk/src/triggers/triggers.php

    r2513575 r2516947  
    22
    33include_once plugin_dir_path( __FILE__ ) . 'wp-admin-bar/trigger.php';
     4
     5function presets_get_ids() {
     6
     7    return get_posts(
     8        array(
     9            'fields'         => 'ids',
     10            'posts_per_page' => -1,
     11            'post_type'      => 'presets',
     12        )
     13    );
     14
     15}
     16
     17function presets_get_current_url( $id ) {
     18
     19    return add_query_arg( 'presets-trigger', $id, $_SERVER['REQUEST_URI'] );
     20
     21}
  • presets/trunk/src/triggers/wp-admin-bar/trigger.php

    r2513575 r2516947  
    66        return;
    77    }
     8
    89    $admin_bar->add_menu(
    910        array(
     
    1920    );
    2021
    21     $presets_ids = get_posts(
    22         array(
    23             'fields'         => 'ids',
    24             'posts_per_page' => -1,
    25             'post_type'      => 'presets',
    26         )
    27     );
    28 
    29     foreach ( $presets_ids as $id ) {
     22    foreach ( presets_get_ids() as $id ) {
    3023
    3124        $admin_bar->add_menu(
     
    3528                'group'  => null,
    3629                'title'  => get_the_title( $id ), // you can use img tag with image link. it will show the image icon Instead of the title.
    37                 'href'   => admin_url( 'edit.php?post_type=presets&presets-trigger=' . $id ),
     30                'href'   => presets_get_current_url( $id ),
    3831                'meta'   => array(
    3932                    'title' => get_the_title( $id ), // This title will show on hover.
     
    4639}
    4740
    48 add_action( 'admin_bar_menu', 'presets_admin_bar_item', 100 );
     41add_action(
     42    'admin_init',
     43    function () {
     44        add_action( 'admin_bar_menu', 'presets_admin_bar_item', 100 );
     45    }
     46);
Note: See TracChangeset for help on using the changeset viewer.