Skip to content

Instantly share code, notes, and snippets.

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@w-perspective
w-perspective / WP generate alt attribute to <img>.php
Last active April 1, 2019 08:08
WP generate alt attribute to <img>(author campusboy)
/**
* Заполняет поле для атрибута alt на основе заголовка изображения при его вставки в контент поста.
*
* @param array $response
*
* @return array
*/
function change_empty_alt_to_title( $response ) {
if ( ! $response['alt'] ) {
$response['alt'] = sanitize_text_field( $response['title'] );
@w-perspective
w-perspective / WordPress Get Category name By label
Last active January 14, 2019 13:30 — forked from agragregra/WordPress Get Category name By label
WordPress Get Category name By label
<?php
$idObj = get_category_by_slug('s_about');
$id = $idObj->term_id;
echo get_cat_name($id);
?>
@w-perspective
w-perspective / diagonal-right.html
Created January 12, 2019 08:14
Svg diagonal line
<svg version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none">
<path d="M 0 0 V 100 H 100 Z" style="fill: white;"></path>
</svg>
@w-perspective
w-perspective / DIV Equal Height
Last active January 8, 2019 14:43 — forked from agragregra/DIV Equal Height
DIV Equal Height with position absolute
<style>
.square {
display: inline-block;
position: relative;
width: 55%;
}
.square_dummy {
margin-top: 100%;
display: block;
}
<?php
$images = getFieldOrder('img');
$i = 0;
foreach($images as $image) {
$i++;
$nuevos = array ("w" => 300, "h" => 200, "zc" => 1, "q" => 100);
$image_thumb = get_image('img', 1, $i, 0, NULL, $nuevos);
$image_link = get_image('img', 1, $i, 0, NULL); ?>
<?php echo $image_thumb; ?><br/>
@w-perspective
w-perspective / Wordpress Menu
Created January 8, 2019 14:36 — forked from agragregra/Wordpress Menu
Wordpress Menu
//functions.php
register_nav_menus(array(
'top_mnu' => 'Top Menu',
));
//Template
wp_nav_menu(array(
'theme_location' => 'top_mnu'
));
@w-perspective
w-perspective / WordPress Category Home
Last active January 8, 2019 14:37 — forked from agragregra/WordPress Category Home
WordPress Category Home
<?php
if ( have_posts() ) : // если имеются записи в блоге.
query_posts('cat=3'); // указываем ID рубрик, которые необходимо вывести.
while (have_posts()) : the_post(); // запускаем цикл обхода материалов блога
?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; // завершаем цикл.
endif;
/* Сбрасываем настройки цикла. Если ниже по коду будет идти еще один цикл, чтобы не было сбоя. */
wp_reset_query();
<?php
$post = $wp_query->post;
if (in_category('cat_label_1')) {
include(TEMPLATEPATH.'/single-cat_label_1.php');
} elseif (in_category('cat_label_2')) {
include(TEMPLATEPATH.'/single-cat_label_2.php');
}
?>
@w-perspective
w-perspective / Wordpress theme-options.php
Last active January 8, 2019 14:30 — forked from agragregra/Wordpress Theme Options
Wordpress theme-options.php
//In Template
<?php
$options = get_option('sample_theme_options');
echo $options['phone1'];
?>
//in functions.php
require_once ( get_stylesheet_directory() . '/theme-options.php' );
//theme-options.php file: