dimanche 1 mai 2016

How to add like event button on event listing page wordpress?

I am using Events Manager plugin (http://ift.tt/1iLlaKo).
Here I want like button for every event on single page as well as on listing page.
So I am using
I recommend this(http://ift.tt/1EVu2L0) plugin.
This work fine on single event page but wont work on listing page.So how can I add short code within listing page?



via Chebli Mohamed

Shipping Rates based on Product Quantity on woocommerce

I want to set shipping cost quantity wise on my woocommerce theme. I want to do this option :

For 1 to 5 products shiping cost will be 15%. More than 5 products whipping cost will be $6.99 .

Can i add this shipping option without a plugin ?



via Chebli Mohamed

get_currentuserinfo is deprecated, unable to find location of the error

I was wondering if someone ever experienced this issue with Wordpress:

Notice: get_currentuserinfo is deprecated since version 4.5! Use wp_get_current_user() instead. In /public_html/wp-includes/functions.php on line 3658

I know I can simply replace it but I need to find the source first. (the file and line mentioned in the notice simply refer to the error message itself.)

So I deactivated all the plugins, it still showed up. The theme I’m using checked out too. I eventually found a plugin (Query Monitor) that should show the exact location of the error, but strangely enough it’s not listed in its overview.

Anyone know what’s left to do? Thanks so much in advance!



via Chebli Mohamed

Wordpress Fatal Error - SQL - Do I suppress?

Been building a custom plugin for a client and I have been working on creating a table and inserting data to Wordpress. I finally have the tables created and the data does indeed insert (although 3 times??).

So I have it working where it sets up everything but I still get the "Plugin could not be activated because it triggered a fatal error." No debug log gets created, nothing in the console, tables are created and data is inserted. Then it breaks.

Can anyone shed light on the statements to see where the error is. My eyes cannot find it and a second site would be helpful.

This is the create table function:

    function db1_install() {
    global $wpdb;
    global $db_version1;
    global $table_name;
    $table_name = $wpdb->prefix . 'myCategories';   
    $charset_collate = $wpdb->get_charset_collate();    
    $sql = "CREATE TABLE $table_name (
        id mediumint(9) NOT NULL,
        item varchar(20) NOT NULL,
        item_cat varchar(20) NOT NULL
        ) $charset_collate;";
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );
    add_option( 'db_version1', $db_version1 );    
    } 
    register_activation_hook( __FILE__, 'db1_install' );

And this is the Data insert function:

function add_categories(){

    global $wpdb;
    $table_name = $wpdb->prefix . 'myCategories';
    $wpdb->query("INSERT INTO $table_name (id,item,item_cat)
    values (1,'item1','cat1'), (2,'item2','cat1'), (2,'item3','cat4')");
    die();
    return true;
    }
    register_activation_hook( __FILE__, 'add_categories');

It does not tell me the error and it inserts the records 3 times!!

I am not using meta or options for a reason and really just nned to figure this out so I can complete my custom pluging.

by the way I am a newbie/novice PHP coder so be gentle. Anyone?



via Chebli Mohamed

Is there a way to make Wordpress metaboxes tabbed easily in plugin?

I created a plugin which has a custom post type, and there are tons of metaboxes there that I would like to have more organized or in a tabbed view.

Something like this plugin:

http://ift.tt/1s8plnc

It's really good and quite simple, but I can't implement the view in my plugin.

Is there a premium or free solution for that ?



via Chebli Mohamed

if title contains string 'aaa','bbb' or ,'ccc' replace field {category[1}

Hello gods of Stackoverflow,

Now i hate to be "that guy" who didnt search properly but i am running into a problem that i need a fix for and can't find a solution i can work with because of my lack in coding skills, my knowledge barely tickles the surface.

Here's the thing.

I am using a tool to import feeds into my website (WP all Import) as woocommerceproducts. But in the categorization the feed suppliers made errors which i want to tackle without emailing them everytime i stumble upon one.

i.e: the title contains words like satchel, bag, clutch etc but the product is categorized as 'jewellery > earrings' in the CSV or XML.

The import tool will ask me where to find the product category, i point it to the node {category[1]}

But when the category is missing or faulty i want it to check the title for certain words, and if present change the value of it to that found word.

something like: 

[if ({title[1]}contains "satchel") {
    category = "bags > satchel",
} else if ({title[1]} contains clutch) {
    category = "bags > clutch",
} else {
    category = {sub_category[1]} #the normal value if nothing was found 
}]

I just can't find the pieces to put the formatting together. I might need to work towards a function that i could expand to generate categories based solely out of presence of certain words in the title but maybe when i get better that would be an option.

I hope i was able to provide a clear view on the problem. The "[ ]" is there because thats how the plugin wants code to be entered instead of a {fieldname[1]}, another example below:

The following was an example of a problem i was able to fix: i needed to replace values like "0/3months/1/2months" to "0-3 months/1-2months" before i replaced the slash"/" with a pipe"|" for wordpress to recognize it as a seperate value.

[str_replace("/","|",
   str_replace("0/3","0-3",
     str_replace("1/2","1-2",
       str_replace("3/6","3-6",{size[1]}))))]

The fields can also be used to call functions but only in the 'pro' version of the plugin.

Any help is very much appreciated, thanks in advance.



via Chebli Mohamed

How to make related Advertisement records show up in a PHP page which belong to different ad zones?

I am working on a WordPress PHP plugin to manage and show advertisement banners on a website.

This image below shows 2 Advertisement zones
- top
- sidebar

An Advertisement zone is a database record. The ad zone is then shown on the page by putting in a PHP function in the page template files or using a WordPress shortcode where the ad zone should exist in the page.

This function for the ad zone then simply pulls in a random Advertisement DB record which has its ad_zone field set to the ID of the Advertisement zone set in the particular function call.

So this image below would have 2 function calls for the ad_zone($id); One for the top and one for the sidebar in the template files.

Now to get on to my question and what I want to do. On some sites like YoutTube and Hulu for examples. They will often show a top and sidebar Advertisement that belong together.

So both my top and sidebar ad zones would load an Advertisement banner for the same website/user at once. Instead of them both loading a random Advertisement, if there was a setting on the Advertisement DB record which indicates that it has a matching Advertisement in another Ad zone, it will then show the pair when one of the ads comes up for selection in the random viewing.

So I am wanting to come up with a solution on how I might make my system do this as well.

  • Each ad zone shows a random Advertisement record for the ads DB table.
  • If the random ad selected to show up in one of the ad zones has a DB entry on it indicating that it has a related/matching Advertisement in another ad zone on the same page, it should then make the other Ad zones show the related Advertisements instead of the other ad zones selecting random ads.

Any ideas how I might achieve this?

Some thoughts:

  • The 1st ad zone to run and select its random Advertisement to show would need to check if it has related ads to show in other zones. If not the first, then the 1st ad zone might select a random ad that has no related records and then the 2nd ad zone might select a random ad which does have a related record in the 1st ad one but since the 1st ad zone already rand and built its output, it would not work!

enter image description here


UPDATE

One idea:

The 1st ad zone function call will select a random Advertisement as usual. If the selected Ad has a related record in other ad zone DB tables, it will save that to a user PHP session.

Now when the next Ad zone function call is ran, before selecting a random ad for itself it will first check the user sessions to see if it should be shown with a matching ad from another Ad zone.

I think this might work!



via Chebli Mohamed