Skip to content

Instantly share code, notes, and snippets.

View kirasiris's full-sized avatar
😍
In love with JavaScript!!

Kevin Uriel Fonseca kirasiris

😍
In love with JavaScript!!
View GitHub Profile
@kirasiris
kirasiris / functions.php
Created July 29, 2019 21:45
WordPress desde cero archivo functions.php
<?php
require_once('bs4Navwalker.php');
require_once('customizer.php');
function theme_setup(){
register_nav_menus(array(
'primary' => __('Primary Menu', 'wordpressfromscratch'),
'secondary' => __('Secondary Menu', 'wordpressfromscratch'),
));
@kirasiris
kirasiris / customizer.php
Created July 25, 2019 19:45
WordPress Custom Theme Selector and Custom Container Selector
<?php
function wpb_customize_register($wp_customize){
/*
*
* SHOWCASE THEME SELECTOR
*
*/
$wp_customize->add_setting('theme_selector', array(
'default' => _x('bootstrap', 'kevinurielfonsecav2'),
'type' => 'theme_mod'
/*
*
* BOOTSTRAP COMMENTS PARA EL ARCHIVO FUNCTIONS.PHP
*
*/
function bootstrap_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
?>
<?php if ( $comment->comment_approved == '1' ): ?>
<li class="media">
@kirasiris
kirasiris / bs4Navwalker.php
Created July 18, 2019 19:00
A Bootstrap Navwalker class for Menu Creations in WordPress
<?php
/**
* Class Name: bs4Navwalker
* GitHub URI: https://github.com/dupkey/bs4navwalker
* Description: A custom WordPress nav walker class for Bootstrap 4 nav menus in a custom theme using the WordPress built in menu manager.
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
class bs4Navwalker extends Walker_Nav_Menu
{
@kirasiris
kirasiris / controller.php
Created April 27, 2018 10:08 — forked from Jakeii/controller.php
Get categories and subcategories in one query, seen many solutions that get the categories and for each category check for subcategories. Uses codeigniter framework, fairly easy to convert to vanilla php if you need. Probably a better storage/display solution than the strange array that I used.
<?php
$cats_result = $this->model->get_categories($swapid);
if ($cats_result->num_rows() > 0) {
$cat_index = $sub_index = $row_index = 0;
do {
$cats[$cat_index]['cat'] = array(
'name' => $cats_result->row($row_index)->cat_name,
'title' => $cats_result->row($row_index)->cat_title
);
@kirasiris
kirasiris / wordpress_breadcrumbs.php
Created April 15, 2018 23:29
Breadcrumb function for WordPress
<?php
// Breadcrumb
function get_breadcrumb() {
if ( is_front_page() ) {
return;
}
if ( get_theme_mod( 'ct_ignite_show_breadcrumbs_setting' ) == 'no' ) {
return;
@kirasiris
kirasiris / preview_image_in_codeigniter.php
Last active February 14, 2018 22:37
Codigo de Javascript para hacer un preview de Imagen antes de subir a base de datos(database)
<!-- Div escondido que se mostrara hasta que haya un valor dentro del elemento <img> -->
<div class="thumbnail" id="div-preview" style="display:none;">
<img alt="Image Display Here" id="image_preview" src="#" />
</div>
<!-- Post Image -->
<div class="form-group">
<?php echo form_label('Upload Image', 'post_image') ?>
<?php
$data = array(
'name' => 'post_image',
<?php
/*
*
*Este metodo trabaja con la version 3.1.6 en adelante de CodeIgniter
*
*/
// Preferencias para subir imagenes
$config['upload_path'] = 'assets/img/posts/';
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
@kirasiris
kirasiris / bootstrap_navbar_styles.css
Last active February 13, 2018 02:39
Different Bootstrap 3.3.7 Styles
/* Orange */
.navbar-orange{
background-color: #dd4814;
}
.navbar-orange .navbar-brand {
color: #ffffff;
}
/* Optional */
.navbar-orange .navbar-brand:hover {
background-color: #97310e;
@kirasiris
kirasiris / codeigniterversion.php
Created February 12, 2018 07:02
Get to know the current CodeIgniter version you're running on
<?php echo CI_VERSION; ?>