Skip to content

Instantly share code, notes, and snippets.

@artes-visuales
Last active August 20, 2021 13:50
Show Gist options
  • Save artes-visuales/5b01100dff94ea1933e4 to your computer and use it in GitHub Desktop.
Save artes-visuales/5b01100dff94ea1933e4 to your computer and use it in GitHub Desktop.
WordPress
//Theme Structure
header.php ...................... Header Section
index.php ......................... Main Section
sidebar.php .................... Sidebar Section
single.php ....................... Post Template
page.php ......................... Page Template
comments.php .................. Comment Template
search.php ...................... Search Content
searchform.php ............ Search Form Template
archive.php ................... Archive Template
functions.php ................ Special Functions
404.php .................... Error Page template
style.css .......................... Style Sheet
<?php wp_tag_cloud(); ?>
<?php wp_list_pages(); ?>
<?php get_calendar(); ?>
<?php wp_list_cats(); ?>
<?php echo c2c_custom('test');?>
<?php
// Limpiar el head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
// Fin limpiar el head
//Add css to wp_head
function child_theme_head_css(){
wp_enqueue_style('animate', get_bloginfo('stylesheet_directory').'/assets/css/animate.css','style-theme');
wp_enqueue_style('glyphicon', get_bloginfo('stylesheet_directory').'/assets/css/glyphicon.css','style-theme');
}
add_action('wp_print_styles', 'child_theme_head_css');
// Logo personalizado en la página de login
function custom_login() {
echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/wp-admin.css" />';
}
add_action('login_head', 'custom_login');
// Personalización de administración
// css personalizado en la página de login
add_action('admin_head', 'my_custom_css');
function my_custom_css() {
echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/wp-admin.css" />';
}
//Quita el acceso al Escritorio al que no sea Admin
add_filter('login_redirect', 'dashboard_redirect');
function dashboard_redirect($url) {
global $current_user;
get_currentuserinfo();
$level = (int) $current_user->wp_user_level;
if ( $level < 10 && $level > 3 ) {
$url = 'wp-admin/post-new.php';
}
return $url;
}
// url personalizada en la página de login
function h1_custom_url(){
return (bloginfo( 'wpurl' ));
}
add_filter('login_headerurl', 'h1_custom_url');
// Cambiar el pie de pagina del panel de Administración
function change_footer_admin() {
echo '(c) 2013 Copyright. Todos los derechos reservados - Web creada por <a href="#">artesvisuales</a>';
}
add_filter('admin_footer_text', 'change_footer_admin');
//miniaturas en admin de entradas
if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
// para entrada y página
add_theme_support('post-thumbnails', array( 'post', 'page' ) );
function fb_AddThumbColumn($cols) {
$cols['thumbnail'] = __('Miniatura');
return $cols;
}
function fb_AddThumbValue($column_name, $post_id) {
$width = (int) 45;
$height = (int) 45;
if ( 'thumbnail' == $column_name ) {
// miniatura de WP 2.9
$thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
// imagen de la galería
$attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
if ($thumbnail_id)
$thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
elseif ($attachments) {
foreach ( $attachments as $attachment_id => $attachment ) {
$thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
}
}
if ( isset($thumb) && $thumb ) {
echo $thumb;
} else {
echo __('Ninguna');
}
}
}
// para entradas
add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
// para páginas
add_filter( 'manage_pages_columns', 'fb_AddThumbColumn' );
add_action( 'manage_pages_custom_column', 'fb_AddThumbValue', 10, 2 );
}
//Bloquear el mensaje de error en la entrada de administración
add_filter('login_errors',create_function('$a', "return null;"));
// Fin personalización de administración
/* Modo mantenimiento
function wpr_maintenace_mode() {
if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
die('Estamos de mantenimiento, no tardes en volver que enseguida terminamos.');
}
}
add_action('get_header', 'wpr_maintenace_mode'); */
// Theme the TinyMCE editor
// You should create custom-editor-style.css in your theme folder
//add_editor_style('custom-editor-style.css');
// Insertar Breadcrumb
function the_breadcrumb() {
if (!is_home()) {
echo '<span class="removed_link" title="&#039;;
echo get_option(&#039;home&#039;);
echo &#039;">';
bloginfo('name');
echo "</span> » ";
if (is_category() || is_single()) {
the_category('title_li=');
if (is_single()) {
echo " » ";
the_title();
}
} elseif (is_page()) {
echo the_title();
}
}
}
// fin breadcrumb
// Avatar image con hCard-compliant photo class
function commenter_link() {
$commenter = get_comment_author_link();
if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
$commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
} else {
$commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
}
$avatar_email = get_comment_author_email();
$avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 50 ) );
echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
}
// end commenter_link
//Desactivar revisiones
function disable_autosave() {
wp_deregister_script('autosave');
}
add_action('wp_print_scripts','disable_autosave');
//Fin desactivar revisiones
//Añadir gestor de enlaces
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
//WOOCOMMERCE
// Override theme default specification for product # per row
function loop_columns() {
return 3; // 3 products per row
}
add_filter('loop_shop_columns', 'loop_columns', 999);
// Mostrar Post ID, Page ID, Media ID, Links ID, Category ID, Tag ID and User ID
if ( ! function_exists( 'catchids_column' ) ):
/**
* Prepend the new column to the columns array
*/
function catchids_column($cols) {
$column_id = array( 'catchids' => __( 'ID', 'catch-ids' ) );
$cols = array_slice( $cols, 0, 1, true ) + $column_id + array_slice( $cols, 1, NULL, true );
return $cols;
}
endif; // catchids_column
if ( ! function_exists( 'catchids_value' ) ) :
/**
* Echo the ID for the new column
*/
function catchids_value( $column_name, $id ) {
if ( 'catchids' == $column_name ) {
echo $id;
}
}
endif; // catchids_value
if ( ! function_exists( 'catchids_return_value' ) ) :
function catchids_return_value( $value, $column_name, $id ) {
if ( 'catchids' == $column_name ) {
$value .= $id;
}
return $value;
}
endif; // catchids_return_value
if ( ! function_exists( 'catchids_css' ) ) :
/**
* Output CSS for width of new column
*/
function catchids_css() {
?>
<style type="text/css">
#catchids {
width: 80px;
}
</style>
<?php
}
endif; // catchids_css
add_action( 'admin_head', 'catchids_css');
if ( ! function_exists( 'catchids_add' ) ) :
/**
* Actions/Filters for various tables and the css output
*/
function catchids_add() {
// For Media Management
add_action( "manage_media_columns" , 'catchids_column' );
add_filter( "manage_media_custom_column" , 'catchids_value' , 10 , 3 );
// For Link Management
add_action( 'manage_link_custom_column', 'catchids_value', 10, 2 );
add_filter( 'manage_link-manager_columns', 'catchids_column' );
// For Category Management
add_action( 'manage_edit-link-categories_columns', 'catchids_column' );
add_filter( 'manage_link_categories_custom_column', 'catchids_return_value', 10, 3 );
// For Category, Tags and other custom taxonomies Management
foreach( get_taxonomies() as $taxonomy ) {
add_action( "manage_edit-${taxonomy}_columns" , 'catchids_column' );
add_filter( "manage_${taxonomy}_custom_column" , 'catchids_return_value' , 10 , 3 );
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) {
add_filter( "manage_edit-${taxonomy}_sortable_columns" , 'catchids_column' );
}
}
foreach( get_post_types() as $ptype ) {
add_action( "manage_edit-${ptype}_columns" , 'catchids_column' );
add_filter( "manage_${ptype}_posts_custom_column" , 'catchids_value' , 10 , 3 );
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) {
add_filter( "manage_edit-${ptype}_sortable_columns" , 'catchids_column' );
}
}
// For User Management
add_action( 'manage_users_columns', 'catchids_column' );
add_filter( 'manage_users_custom_column', 'catchids_return_value', 10, 3 );
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) {
add_filter( "manage_users_sortable_columns" , 'catchids_column' );
}
// For Comment Management
add_action( 'manage_edit-comments_columns', 'catchids_column' );
add_action( 'manage_comments_custom_column', 'catchids_value', 10, 2 );
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) {
add_filter( "manage_edit-comments_sortable_columns" , 'catchids_column' );
}
}
endif; // catchids_add
add_action( 'admin_init', 'catchids_add' );
?>
<?php bloginfo('html_type'); ?>
<ul id="menu">
<li <?php if(is_home()) { ?> class="current-cat"< ?php } ?>>
<a href="<?php bloginfo('home'); ?>">Home</a></li>
< ?php wp_list_categories('title_li=&orderby=id'); ?>
</ul>
<ul id="menu">
<li <?php if(is_home()) { ?> class="current_page_item"< ?php } ?>>
<a href="<?php bloginfo('home'); ?>">home</a></li>
< ?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
</ul>
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Allow: /wp-content/themes/
Allow: /wp-content/plugins/
Allow: /wp-content/uploads/
Allow: /wp-includes/css/
Allow: /wp-includes/js/
Allow: /wp-includes/images/
< ?php get_header(); ?>
< ?php get_sidebar(); ?>
< ?php get_footer(); ?>
< ?php comments_template(); ?>
<?php bloginfo('url'); ?>
<?php query_posts('category_name=Category&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
// The Stuff... Custom HTML & PHP Code
<?php endwhile;?>
<?php bloginfo('charset'); ?>
<?php bloginfo('description'); ?>
<?php bloginfo('pingback_url'); ?>
<?php bloginfo('rss2_url'); ?>
<?php bloginfo('stylesheet_url'); ?>
<?php bloginfo('template_url'); ?>
<?php if(have_posts());?>
<?php while(have_posts()); the_post();?>
// The Stuff... Custom HTML & PHP Code
<?php else;?>
<?php endif;?>
/*
Theme Name: Wordpress
Theme URI: http://wordpress.org/
Description: Test Blog
Version: 1.6
Author: artesvisuales
Author URI: http://artesvisuales.com
Tags: chuleta, cheat, referencia
*/
<?php timer_stop(1);?>
<?php bloginfo('name'); ?>
<?php bloginfo('wpurl'); ?>
<?php the_search_query();?>
UPDATE wp_options SET option_value = REPLACE ( option_value, 'dominioantiguo.com', 'dominionuevo.com' );
UPDATE wp_posts SET guid = REPLACE ( guid, 'dominioantiguo.com', 'dominionuevo.com' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, 'dominioantiguo.com', 'dominionuevo.com' );
UPDATE wp_postmeta SET meta_value = REPLACE ( meta_value, 'dominioantiguo.com', 'dominionuevo.com' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment