Skip to content

Instantly share code, notes, and snippets.

View rodica-andronache's full-sized avatar
🦄

Rodica-Elena Irodiu rodica-andronache

🦄
  • themeisle.com
  • Bucharest
View GitHub Profile
@rodica-andronache
rodica-andronache / gist:b4ea26fad7cca88d8625
Created May 12, 2015 13:19
Add image size, for media uploader
add_image_size( 'zerif-testimonial', 73, 73, true );
add_image_size( 'zerif-clients', 130, 50, true );
add_filter('image_size_names_choose', 'zerif_image_sizes');
function zerif_image_sizes($sizes) {
$zerif_addsizes = array( "zerif-our-focus" => __( "Our focus","zerif"), "zerif_our_team_photo" => __("Our team","zerif"), "zerif-testimonial" => __("Testimonial", "zerif"), "zerif-clients" => __("Client logo","zerif") );
$zerif_newsizes = array_merge($sizes, $zerif_addsizes);
return $zerif_newsizes;
@rodica-andronache
rodica-andronache / gist:0f8b502fdfb84009132f
Last active August 29, 2015 14:21
Custom size for files uploaded via media uploader ( for custom widgets)
add_image_size( 'zerif-our-focus-widget', 125, 125, true );
global $wpdb;
$our_focus_attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", esc_url($instance['image_uri']) )); /* attachement id by attachement url */
$aa = wp_get_attachment_image_src( $attachment[0], 'zerif-our-focus-widget' );
echo $aa[0]; /* url-ul imaginii */
SAU varianta mai buna:
@rodica-andronache
rodica-andronache / gist:d9fe761f5ae3e4d12e38
Last active August 29, 2015 14:16
Add default widgets in sidebar
http://wordpress.stackexchange.com/questions/26557/programmatically-add-widgets-to-sidebars
/**
* Super simple widget.
*/
class T5_Demo_Widget extends WP_Widget
{
public function __construct()
{ // id_base , visible name
parent::__construct( 't5_demo_widget', 'T5 Demo Widget' );
http://codex.wordpress.org/Create_A_Network
@rodica-andronache
rodica-andronache / gist:2b5ad9d4fe6fc9d50999
Created November 10, 2014 12:13
Inregistrare custom post type
add_action( 'init', 'zerif_create_post_type' );
function zerif_create_post_type() {
/* portofolio */
register_post_type( 'portofolio',
@rodica-andronache
rodica-andronache / gist:54f3ea95bcaf76435e55
Created October 31, 2014 13:27
color picker in wordpress widget
class Color_Picker_Widget_25809 extends WP_Widget {
/**
* Widget constructor.
*
* @since 1.0
*
* @access public
*/
public function __construct() {
@rodica-andronache
rodica-andronache / gist:ae614756c938694d5f86
Last active April 25, 2016 06:47
Woocommerce extension
http://speakinginbytes.com/2014/07/woocommerce-settings-tab/
If you’re building a WooCommerce extension the easiest thing you can do to improve your UI is to put all WooCommerce settings where users can find them – on a new WooCommerce settings tab.
1 – Add a New WooCommerce Settings Tab
You just need to add one extra array item to the woocommerce_settings_tabs_array filter.
<?php
class WC_Settings_Tab_Demo {
@rodica-andronache
rodica-andronache / gist:dd93c70c8df580136997
Created October 6, 2014 15:51
Wordpress Admin Notices
http://wptheming.com/2011/08/admin-notices-in-wordpress/
http://www.paulund.co.uk/rewrite-urls-wordpress
jQuery('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
if (target.length) {
jQuery('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}