Skip to content

Instantly share code, notes, and snippets.

View gydoar's full-sized avatar
🕶️
Coding

Andrés Vega gydoar

🕶️
Coding
View GitHub Profile
@gydoar
gydoar / index.php
Created July 26, 2017 19:51
Cabecera del plugin
<?php
/*
Plugin Name: Flexslider plugin
Plugin URI: https://github.com/gydoar/flexslier-plugin
Description: Plugin creado con Flexslider para WordPress
Version: 1.0
Author: ANDRES DEV
Author URI: https://andres-dev.com
License: GPL2
*/
@gydoar
gydoar / index.php
Created July 26, 2017 19:52
Registrando post type plugin
<?php
function post_type_flexslider() {
register_post_type( 'flexslider',
array( 'labels' => array(
'name' => __( 'Flexslider', 'andres-dev' ),
'singular_name' => __( 'Flexslider', 'andres-dev' ),
'all_items' => __( 'Todos los sliders', 'andres-dev' ),
'add_new' => __( 'Agregar nuevo', 'andres-dev' ),
<!-- Place somewhere in the <head> of your document -->
<link rel="stylesheet" href="flexslider.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="jquery.flexslider.js"></script>
// inicializamos con la función de flexslider()
jQuery(document).ready(function($) {
$('.flexslider').flexslider({
animation: "slide"
});
});
<?php
// Registrando estilos
function flx_registrar_estilos() {
// registrar
wp_register_style('flx_styles', plugins_url('css/flexslider.css', __FILE__));
// colocar
wp_enqueue_style('flx_styles');
}
@gydoar
gydoar / index.php
Created July 26, 2017 23:39
Thumbnails
<?php
add_image_size('thum-flx', 600, 280, true); // declaramos el nombre del thumbnail 'thum-flx' y su tamaño
add_theme_support( 'post-thumbnails' ); // agregamos soporte para que pueda funcionar
@gydoar
gydoar / index.php
Created July 26, 2017 23:42
Estructura de flexslider
<?php
<div class="flexslider">
<ul class="slides">
<li>
<img src="slide1.jpg" />
</li>
<li>
<img src="slide2.jpg" />
</li>
<li>
@gydoar
gydoar / index.php
Created July 26, 2017 23:43
Función para el plugin
<?php
// Creamos la función para mostrarlo desde el frontend
function flx_funcion($type='thum-flx') {
$args = array(
'post_type' => 'flexslider',
'posts_per_page' => 5
);
$result = '<div class="flexslider">';
$result .= '<ul class="slides">';
@gydoar
gydoar / index.php
Created July 26, 2017 23:45
Shortcode
<?php
// creamos un shortcode llamado [flx-shortcode] para llamarlo donde deseemos
add_shortcode('flx-shortcode', 'flx_funcion');
<?php
/**
* Theme support Blocks
* @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/
*/
function andres_gutenberg_default_colors()
{