Skip to content

Instantly share code, notes, and snippets.

@anegoda1995
anegoda1995 / [nameOfYourModuleInPrestaShopFileName].php
Created March 31, 2017 14:41
[[[PrestaShop]]] create module for PrestaShop CMS (complete code of main file)
<?php
/*
This is main file example of new empty module for PrestaShop 1.7 (yeah, 1.7 not 1.6);
There you need to change name of module, name of class, and 'ANY_VALUE' for those what you need;
This code you can copy to your main file and that is! Work!
Addition information you can find at: [[[http://doc.prestashop.com/display/PS16/Creating+a+first+module]]] where I taught it
*/
@anegoda1995
anegoda1995 / [anyfilename].php
Created March 31, 2017 14:24
[[[PrestaShop]]] add new product by script in PrestaShop CMS
<?php
require('./config/config.inc.php');
//$tmp = new ProductCore();
$product = new ProductCore();
$product->ean13 = 9999999999999;
$product->name = array((int)Configuration::get('PS_LANG_DEFAULT') => 'Test importu');;
$product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => 'test-importu');
$product->id_category = 2;
@anegoda1995
anegoda1995 / functions.php
Last active March 14, 2017 08:12
Register widget area (sidebar) in WordPress template functions.php file
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function [name_of_theme]_widgets_init()
{
register_sidebar(array(
'name' => esc_html__('Name of widget area', '[name_of_theme]'),
'id' => '[widget_area_unique_name]', //OnLy LoWeRcAsE!!!!!!!!!!!!!!!!!! else not save widgets on area
@anegoda1995
anegoda1995 / functions.php
Last active March 14, 2017 07:50
Create widget by write code in functions.php of specified theme.
/*
* example of simple widget
*/
// Creating the widget popularNews
class nameOfWidget extends WP_Widget
{
function __construct()
{
@anegoda1995
anegoda1995 / gist:8ae197e79823130ca4fc7869a01b783b
Created February 9, 2017 14:28
Class for realise filter by data from page
<?php
require_once '../../../wp-load.php';
$bloginfo = get_bloginfo('template_url');
$jsonString = stripslashes($_POST['filter']);
$filterObj = new Filter($jsonString);
/*
@anegoda1995
anegoda1995 / [any_template_file].php
Last active January 27, 2017 08:00
This snippet for out last 9 woocommerce products
<?php
$args = array(
'post_type' => 'product',
'stock' => 1,
'posts_per_page' => 9,
'orderby' => 'date',
'order' => 'DESC');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
global $product;
@anegoda1995
anegoda1995 / functions.php
Created January 26, 2017 07:47
Change HTML for wp_PageNavi plugin in WordPress
######################
# Change html pagenavi for transform like bootstrap
######################
//attach our function to the wp_pagenavi filter
add_filter( 'wp_pagenavi', 'wd_pagination', 10, 2 );
//customize the PageNavi HTML before it is output
function wd_pagination($html) {
$out = '';
@anegoda1995
anegoda1995 / [any_template_file].php
Last active January 26, 2017 07:49
Code for getting posts by WP_Query (can use pagination for like this posts)
<ul>
<div id="container">
<div id="content" role="main">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('category_name' => 'news',
'paged' => $paged, 'post_type' => 'post');
$postslist = new WP_Query($args);