Affichage des articles dont le libellé est wordpress. Afficher tous les articles
Affichage des articles dont le libellé est wordpress. Afficher tous les articles

samedi 2 août 2014

How to: Speed up your WordPress site with gzip compression, accélérer wordpress par gzip


aciver la compression gzip pour les données wordpress pour accélerer l'affichage .

les serveur de godaddy support la copression gzip :
http://support.godaddy.com/help/article/6946/enabling-mod_deflate-with-your-hosting-account


pour l'activer sur wordpress ajouter les lignes suivantes à votre .htaccess de la racine :

# BEGIN GZIP
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png
# END GZIP

pour tester si la compression est active :
http://www.whatsmyip.org/http-compression-test/?url=d3d3LnNvdWthc2ZpLmNvbQ==

ou bien sr chrome lancer un audit (F12=>audit) et verifier si chrome n'indique pas la compression gzip

jeudi 10 juillet 2014

compter le nombre d'un custom post expiré et afficher l'alerte dans l'admin bar



compter le nombre d'un custom post 'courrier' expiré et afficher l'alerte dans l'admin bar

si on utilise la methode avec wp_query on tombe dans un probleme lors de l'ajout d'un nouveau article courrier.

donc la solution est de passer par une requet sql direct

et attribuer la fonction à un hook

//////////////////////////////////////////////////////////////////



function sfn_show_expire(){
    global $wpdb;
$i=0;
$non_traite=0;
    $server_time = date('mdy');
    $result = $wpdb->get_results("SELECT * FROM wp_posts WHERE post_type = 'courrier' AND post_status = 'publish'");
    if( !empty($result)) foreach ($result as $a){
        $show_time = get_the_time('mdy', $a->ID );





$custom = get_post_custom($a->ID);
 $delai = $custom["delai"][0];
 $date_recu = $custom["Date"][0];
 $etat = $custom["etat"][0];
 $personne = $custom["personne"][0];
 //$date_recu = date("Y-m-d",$date_recu);
//increment 2 days
$date_expiration = strtotime( $date_recu."+".$delai." days");
$date_expiration = date("Y-m-d",$date_expiration );
$date_now=date("Y-m-d");//date actuelle
 $Objet = $custom["Objet"][0];





        if ($date_now>$date_expiration || $date_now==$date_expiration ){


$i++;
            if( $etat=='Non traité'){$non_traite++;}

        }
    } // end foreach

 global $wp_admin_bar;
/* $args = array(
        'id' => 'mbe_testimonials_pending',
        'href' => admin_url('./extranet/?page_id=939', 'http'),
        'parent' => 'top-secondary'
    );*/
if($non_traite > 0) $disp2=':<span class="mbe-ab-text" style="
    color: red;
" >'.$non_traite.' '.'messages non traités</span>';



        $display = '<a href="/extranet/?page_id=939"><span class="mbe-ab-text" style="
    color: yellow;
" >'.' Alerte'.' '.$i.' '.' courriers expirés</span>'.' '.$disp2.'</a>';

 $args['title'] = $display;
    $wp_admin_bar->add_node($args);

}

add_action('wp_before_admin_bar_render', 'sfn_show_expire', 999);

lundi 28 avril 2014

creer un custom category type et utiliser wp_dropdown_categories menu pour lister les valeur

1- dans function.php

définiser la nouvelle taxonomy :



add_action( 'init', 'addresse_init' );

function addresse_init() {
// create a new taxonomy

$labels = array(

'name' => __( 'adr Categories', APP_TD ),

'singular_name' => __( 'Annonce Category', APP_TD ),

'search_items' => __( 'Search Annonce Categories', APP_TD ),

'all_items' => __( 'All Categories', APP_TD ),

'parent_item' => __( 'Parent Annonce Category', APP_TD ),

'parent_item_colon' => __( 'Parent Annonce Category:', APP_TD ),

'edit_item' => __( 'Edit Annonce Category', APP_TD ),

'update_item' => __( 'Update Annonce Category', APP_TD ),

'add_new_item' => __( 'Add New Annonce Category', APP_TD ),

'new_item_name' => __( 'New Annonce Category Name', APP_TD ),

'add_or_remove_items' => __( 'Add or remove Annonce categories', APP_TD ),

'menu_name' => __( 'adr', APP_TD ),

);



$args = array(

'labels' => $labels,

'public' => true,

'show_in_nav_menus' => true,

'show_ui' => true,

'show_tagcloud' => false,

'hierarchical' => true,



'query_var' => true,

'rewrite' => array( 'slug' => 'listings/category', 'with_front' => false ),

);



register_taxonomy( VA_LISTING_ADDRESSE, VA_LISTING_PTYPE, $args );
}


2-dans la page que vous voulez appeler le dropdwon :

<div class="form-field">
<?php wp_dropdown_categories( array(
    'walker'=> new SH_Walker_TaxonomyDropdown(),
'taxonomy' => VA_LISTING_ADDRESSE,
'hide_empty' => false,
'hierarchical' => true,
'name' => VA_LISTING_ADDRESSE,
/* 'selected' => $listing->category,*/
'show_option_none' => __( 'Selectionner une Cat&eacute;gorie', APP_TD ),
'class' => 'required',
'orderby' => 'id',
'value'=>'slug'

//'id' => 'ba3333'.$taxonomy

  ) ); ?>
 </div>

lundi 21 avril 2014

category group list get slug instead id

pour avoir un slug dans un url au lieu de id qui ne donne pas de resultat
have to resolve


http://stackoverflow.com/questions/14078572/how-to-change-value-for-options-and-select-in-wp-dropdown-categories

vendredi 11 avril 2014

facebook pagination wordpress problem

http://www.shayatik.com/2014/03/facebook-plugin-breaks-wordpress-pagination/#comment-41

best sol is :

When does pagination issue by Facebook WordPress plugin appears?

  • Only on homepage
  • If you are using “Post name” option in Permalink Settings
  • If you are using “Static” homepage option in your Reading Settings which means you are using some custom page template to display your posts in a default loop
The problem with this issue is that WordPress actually generates proper pagination link, (i.e. yourwebsite.com/page/2), but it is somehow always redirected to your home page.

Solution

This handy snippet should do a trick. Make sure it is included somewhere in thefunctions.php file of your theme.
/* Fix pagination issue caused by Facebook plugin */

function meks_fb_plugin_pagination_fix() {

  //Check if plugin is activated and if we are on the homepage
  if(class_exists('Facebook_Loader') && is_front_page()){
    global $wp_query;
    $page = get_query_var('page');
    $paged = get_query_var('paged');

    //Check if we are trying to reach pagination link
    if($page > 1 || $paged > 1){
      unset($wp_query->queried_object);
     }

  }

}

add_action( 'wp', 'meks_fb_plugin_pagination_fix', 99 );

jeudi 10 avril 2014

surcharger l'affichage de wordpress add_action

le code original
<?php
/**
* Fires following the 'Password' field in the login form.
*
* @since 2.1.0
*/
do_action( 'login_form' );
?>

pour le charger dans le plugin on utilise

add_action('login_form', 'fction');

et on defini le code à ajouter dans la fct fction

exp pour ajouter un affichage à l'affichage original 

vendredi 21 février 2014

redirection wordpress


dans controller.php
function template_include( $path ) {
if ( !current_user_can( 'edit_listings' ) ){
//return locate_template( 'create-listing-no-auth.php' );
 wp_redirect( '/wp-login-toadd-annonce.php' );
exit();

}

page/2 uo paged=2

problème dfe permalik et des pages précdents et suivantes:

l'url des pages se transforme en page/2 or en utilisant permalink /nom... ca ne march e pas donc
j'ai du changer dans general-template.php

pour forcer les numéro de pages

i.com/?paged='. $next_page_badr . '">' . $next_text . '</a>';

dimanche 16 février 2014

wordpress custom redirection

function va_redirect_to_front_page() {
    if (isset($_GET['redirect_to'])) {
if($_GET['redirect_to']=="crer-annonce-2")
         wp_redirect( 'crer-annonce-2' );
else
wp_redirect( $_GET['redirect_to'] );
        exit();
    }
else
wp_redirect( 'dashboard' );
exit();
}

creat this funciton in theme/includes/core
don't forget to add action

change max pic uploaded or featured (vantage)

dans /vantage/function.php
chnage this values
define( 'VA_MAX_FEATURED', 5 );
define( 'VA_MAX_IMAGES', 5 );

Get Related Posts For Custom Post Type By Category

how to get related post with custom ones :

http://isabelcastillo.com/get-related-posts-custom-taxonomy-category

mercredi 29 janvier 2014

Nombre total de pages vues