Skip to content

Instantly share code, notes, and snippets.

View jandrodev's full-sized avatar

jandrodev

View GitHub Profile
// Widget Base Code
add_action("widgets_init", array('Widget_name', 'register'));
class Widget_name {
function control(){
echo 'I am a control panel';
}
function widget($args){
echo $args['before_widget'];
@jandrodev
jandrodev / widget.php
Created May 25, 2015 14:47
Angular ng-show Basic Example
<!-- Angular ng-show Basic Example -->
<button ng-click="mostrarInput()">Contacto</button>
<input type="text" placeholder="Contacto" ng-show="mostrar">
<script>
var u87 = angular.module( 'u87', [] );
u87.controller( 'mainController',['$scope', function($scope) {
@jandrodev
jandrodev / contacto.php
Created May 26, 2015 07:54
Wordpress Basic Query With tax_query
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => '3',
'tax_query' => array(
array(
'taxonomy' => 'localizacion',
'field' => 'slug',
'terms' => 'home'
)
@jandrodev
jandrodev / functions.php
Created May 29, 2015 12:17
Recibe el contenido y el número de caracteres y corta ese contenido por ese número pasado.
/**
* Recibe el contenido y el número de caracteres y corta ese contenido por ese número pasado.
*
* @param $content
* @param $letter_count
*/
function cortar_contenido( $content , $letter_count ){
$striped_content = strip_shortcodes($content);
$striped_content = strip_tags($striped_content);
$excerpt = mb_substr($striped_content, 0, $letter_count );
@jandrodev
jandrodev / functions.php
Created June 8, 2015 15:17
Función paginador y aplicación en archivo de plantilla.
function paginador() {
global $wp_query;
$int = 999999999;
echo paginate_links( array(
'base' => str_replace( $int, '%#%', esc_url( get_pagenum_link( $int ) ) ),
'format' => '?paged=%#%',
'prev_text' => __(' Anterior '),
'next_text' => __(' Siguiente '),
@jandrodev
jandrodev / functions.js
Created June 18, 2015 15:38
Función para introducir sólo números.
function validaSoloNumeros() {
if ((event.keyCode < 48) || (event.keyCode > 57))
event.returnValue = false;
}
@jandrodev
jandrodev / u87.php
Created June 23, 2015 14:37
Paginador de posts
function post_prev_next() {
echo '<div class="paginador">';
$prev_post = get_previous_post();
if ( !empty( $prev_post ) ) :
echo '<div class="post-prev">
<a href="'; echo get_permalink( $prev_post->ID ); echo '">Anterior</a>
</div>';
endif;
@jandrodev
jandrodev / u87.php
Created June 23, 2015 15:24
Gestión de Meta Box básica en posts
add_action( 'add_meta_boxes', 'post_options' );
add_action( 'save_post', 'post_options_save_data' );
function post_options() {
add_meta_box('post_meta_box_mobile', 'Título de la sección', 'post_meta_box_mobile', 'post', 'normal', 'high');
}
function post_meta_box_mobile($post) {
@jandrodev
jandrodev / form.php
Last active August 29, 2015 14:23
2 PHP Landing in Drupal
drupal_set_html_head('<script type="text/javascript" src="/..ruta../functions.js"></script>');
// Landing 1 Submit
if (isset($_POST['submit'])) {
$check = $_POST['check'];
if (!empty($check)) {
$n = count($check);
@jandrodev
jandrodev / u87.php
Created July 7, 2015 08:19
Wordpress Widget Base Code
// Widget Base Code
class My_Widget extends WP_Widget {
function My_Widget() {
// Nombre, decsripción, etc. del widget
parent::WP_Widget(false, $name = 'Nombre', $widget_options = array('description' => 'Descripción'));
}
function widget($args, $instance) {
// Muestra el contenido del widget