PHP date to JS date

Kako pouzdano iz PHP-a setapirati JS date

$tz = new DateTimeZone($this_city_tz);
$date = new DateTime();
$date->setTimeZone($tz);
$date_time = $date->format('Y-m-d H:i:s');
$date_time_js = $date->format('Y/m/d H:i:s');

var currentDate = new Date('<?php echo gmdate("r", strtotime($date_time_js)); ?>');

console.log(currentDate);

 

Edit user profile screen

function am2_tv_show_usermeta_fields($user) {
?>
    <h3>Promotor information</h3>
    <table class="form-table">
        <tr>
            <th><label for="am2_promotor_type">Type</label></th>
            <td>
                <?php
                    $selected_option = get_the_author_meta( 'am2_promotor_type', $user->ID );
                 ?>
                <select name="am2_promotor_type" id="am2_promotor_type">
                    <option selected value="">Please select something...</option>
                    <option value="basic" <?php if($selected_option == 'basic'){ echo 'selected'; } ?> >Basic</option>
                    <option value="featured" <?php if($selected_option == 'featured'){ echo 'selected'; } ?> >Featured</option>
                    <option value="premium" <?php if($selected_option == 'premium'){ echo 'selected'; } ?> >Premium</option>
                </select>
                <span class="description">Please select promotor type.</span>
            </td>
        </tr>
</table>
<?php
}

function am2_tv_update_usermeta_fields( $user_id ) {

    if ( !current_user_can( 'administrator', $user_id ) ){
        return false;
    }

    update_usermeta( $user_id, 'am2_promotor_type', $_POST['am2_promotor_type'] );
}


add_action( 'show_user_profile', 'am2_tv_show_usermeta_fields', 10, 2 );
add_action( 'personal_options_update', 'am2_tv_update_usermeta_fields', 10, 2 );
add_action( 'edit_user_profile_update', 'am2_tv_update_usermeta_fields', 10, 2 );
add_action( 'edit_user_profile', 'am2_tv_show_usermeta_fields', 10, 2 );

 Source

See all SQL queries

$customPosts = new WP_Query($yourArgs);
echo "Last SQL-Query: {$customPosts->request}";

OR

First, put this in wp-config.php:

define( 'SAVEQUERIES', true );

Then in the footer of your theme put this:

<?php
if ( current_user_can( 'administrator' ) ) {
    global $wpdb;
    echo "<pre>";
    print_r( $wpdb->queries );
    echo "</pre>";
}
?>

 

Source

Add new fields to custom taxonomies

function am2_cities_tax_create() {
    // this will add the custom meta field to the add new term page
    ?>
    <div class="form-field">
        <label for="term_meta[time_zone]">Time Zone</label>
        <input type="text" name="term_meta[time_zone]" id="term_meta[time_zone]" value="">
        <p class="description">If unusure, please check <a href="http://www.timeanddate.com/worldclock/">here.</a></p>
    </div>

<?php
}
add_action( 'cities_add_form_fields', 'am2_cities_tax_create', 10, 2 );


function am2_cities_tax_update($term) {
    // this will add the custom meta field to the update term page
    // put the term ID into a variable
    $t_id = $term->term_id;

    // retrieve the existing value(s) for this meta field. This returns an array
    $term_meta = get_option( "taxonomy_$t_id" );
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="term_meta[time_zone]">Time Zone</label></th>
        <td>
            <input type="text" name="term_meta[time_zone]" id="term_meta[time_zone]" value="<?php echo esc_attr( $term_meta['time_zone'] ) ? esc_attr( $term_meta['time_zone'] ) : ''; ?>">
            <p class="description">If unusure, please check <a href="http://www.timeanddate.com/worldclock/">here.</a></p>
        </td>
    </tr>
<?php
}

add_action( 'cities_edit_form_fields', 'am2_cities_tax_update', 10, 2 );

function am2_cities_tax_custom_meta_save( $term_id ) {
    if ( isset( $_POST['term_meta'] ) ) {
        $t_id = $term_id;
        $term_meta = get_option( "taxonomy_$t_id" );
        $cat_keys = array_keys( $_POST['term_meta'] );
        foreach ( $cat_keys as $key ) {
            if ( isset ( $_POST['term_meta'][$key] ) ) {
                $term_meta[$key] = $_POST['term_meta'][$key];
            }
        }
        // Save the option array.
        update_option( "taxonomy_$t_id", $term_meta );
    }
}
add_action( 'edited_cities', 'am2_cities_tax_custom_meta_save', 10, 2 );
add_action( 'create_cities', 'am2_cities_tax_custom_meta_save', 10, 2 );