lundi 5 octobre 2015

PHP WordPress Plugin - How to display a div on the static homepage only?

This is my first time building a plugin for WordPress. I got the basics down but now I am trying to display a div on the bottom right corner, more like a small pop-up on the bottom right side of the front page only. The PHP code that I've uploaded did not work, it kept crashing my website.

Where is my mistake?

Please explain your answers. Thank you!

Code:

<?php
/*
Plugin Name: My First Plugin
Plugin URL: http://ift.tt/1VC3cMl
Description: An awesome facebook popup plugin that will amaze you!
Author: Martin
Version: 1.0
Author URL: http://ift.tt/1VC3cMl
*/
add_action('admin_menu', 'myfirstplugin_admin_actions');
function myfirstplugin_admin_actions() {
    add_options_page('MyFirstPlugin', 'MyFirstPlugin', 'manage_options', __FILE__, 'myfirstplugin_admin');
}

function myfirstplugin_admin()
{
?>
<style>
    .wrap { 
        width:100%;
        height:auto;
        }

    .popup {
        position:fixed;
        bottom:0;
        right:0;
        width:325px;
        height:200px;
        background-color:#09f;
    }
</style>


    <div class="wrap">

    <h1>Hello World!</h1><br>
    <h4>Hope you like my awesome popup!</h4>

    </div>



<?php if(is_front_page()) {
        <div class="popup">Testing Div Tag On The Bottom Right Corner...</div>
    }
?>
<?php
}
?>



via Chebli Mohamed

How do I change the name of this sub-directory?

Long time listener, first time caller. Thank you all for your consideration. If you check out my dev site here: http://ift.tt/1GsZ36m

You'll see i'm using a wordpress theme that is built for lawyers/attorneys and not accountants like I am trying to pull off. How can I switch the "attorney" part in the URL path to something more general like "team" or "accountant"?

I'm okay if the back-end part (i.e. the Wordpress Dashboard functions) are labelled "attorney" (as they do now), as long as the user-side doesn't show "attorney".

Any help? I'm not a trained back-end developer, as you may be able to tell. Thanks!



via Chebli Mohamed

How to make a custom page in Wordpress

Hi I'd like to create a totally custom page in wordpress where I'd add a lot of php code so I would prefer not to create it as a wordpress 'Page', but as a file 'filename.php' in my theme directory. Of course in that page I need to include wp functions and stuff and I plan to do it with require_once("../../../../wp-load.php");.

My problem is, how do I set the header info for a custom page like that (title, meta description etc..) and how do I add a rewrite rule to make it reachable like "website.dom/pagename". Thanks in advance for any answer, and even if you tell me that the best way is to use wordpress default "Add New Page", I'd prefer not to use any script to insert php code in the page, thanks.



via Chebli Mohamed

How to include authors (users) in the results for the native WordPress search?

Does anyone knows a way to include authors as part of the search results in the native wordpress theme without plugins?

Thanks



via Chebli Mohamed

Exclude page from a wordpress sitemap

I came across a tutorial on the internet for creating a sitemap in WordPress. It does what I want - it lists all pages and posts on the website however I was wondering if it was possible to exclude a page from the sitemap. In this case I want to exclude the sitemap link. Is it possible to do this? I have included the code for the sitemap below.

<?php
/*
Template Name: Sitemap
*/

get_header(); ?>


<?php if ( have_posts() ) : while( have_posts() ) : the_post();
        the_content();
endwhile; endif; ?>

<h2>Pages</h2>
<ul>
<?php
// Add pages seprated with comma[,] that you'd like to hide to display on sitemap
wp_list_pages(
  array(
    'exclude' => '',
    'title_li' => '',
  )
);
?>
</ul>

<h2>Posts</h2>
<?php
// Add categories seprated with comma (,) you'd like to hide to display on sitemap
$cats = get_categories('exclude=');
foreach ($cats as $cat) {
  echo "<ul>";
  query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
  while(have_posts()) {
    the_post();
    $category = get_the_category();
    // Only display a post link once, even if it's in multiple categories
    if ($category[0]->cat_ID == $cat->cat_ID) {
      echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
    }
  }
  echo "</ul>";
}
?>

<?php get_footer(); ?>

I am aware that the comments within the code give me some idea as to where to list the pages I want to hide however I am unsure as to how to do this. If anyone can help me it would be much appreciated.

Many Thanks.



via Chebli Mohamed

Embeded Youtube 360 video doesn't work in iOS Safari

Is there a way to embed a youtube video in a wordpress post that lets the 360 video work?

I made this test video, and it works everywhere I've tested so far except when I view it in iOS Safari.

The video plays, but the 360 environment doesn't function at all.

Thanks for any leads in figuring this out.



via Chebli Mohamed

WooCommerce: issue setting attributes with wp_set_object_terms

I need to set product's attributes via PHP code. According to other threads on StackOverflow, there's the method wp_set_object_terms. Unfortunately it is not working as it is supposed to do in my case:

For example, there is an attribute named "Hersteller", slug "hersteller". And there is a product, ID 593, with no "hersteller" attribute set.

I tried the following code to fill the attribute:

wp_set_object_terms(593, 'Alpina', 'pa_hersteller' , false);

When I'm attempting to display the attribute on the product page, there is no output, so it seems that the wp_set_object_terms process hasn't been successful. Following code produces an empty output:

$product->get_attribute('hersteller');

Furthermore, the attribute "hersteller" isn't even listed in the attribute list in the admin backend menue.

To debug the problem I've also tried the following code:

$attributes = get_post_meta( 593,  '_product_attributes' ); 
print_r($attributes);

resulting in the following output:

Array ( [0] => Array ( [pa_marken] => Array ( [name] => pa_marken [value] => [position] => 0 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_kategorien] => Array ( [name] => pa_kategorien [value] => [position] => 1 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_referenznummer] => Array ( [name] => pa_referenznummer [value] => [position] => 2 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_herstellergarantie] => Array ( [name] => pa_herstellergarantie [value] => [position] => 3 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_schlagwoerter] => Array ( [name] => pa_schlagwoerter [value] => [position] => 4 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_lieferzeit] => Array ( [name] => pa_lieferzeit [value] => [position] => 5 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) ) )

Am I using the wp_set_object_terms method essentially wrong? I don't know what to do anymore now. May anyone here can help me? Thanks!



via Chebli Mohamed

User meta updating giving no value

So, I have the following to update the user meta:

<?php if ( is_user_logged_in() ) { ?>
    <?php echo '<input class="input" type="text" id="rhc_phone" name="rhc_phone" placeholder="Phone number" value="' .$current_user -> rh_phone. '"/>' ;?>                          
    <?php update_user_meta( $current_user->ID, 'rh_phone', esc_attr( $_POST['rhc_phone'] ) ); ?>            
<?php }else{ ?>
        <input class="input" type="text" id="rhc_phone" name="rhc_phone" placeholder="Phone number" value=""/>
<?php } ?>

However when I click submit, there is no value (not even the previous value).

What am I doing wrong?

Thanks!



via Chebli Mohamed

Woocommerce (Wordpress): How to get the Product when a customer buy a Product?

i just like to get the Product and Amount of the Product when a buyer buy a Product inside my Woocommerce-Plugin. So i can send this Action to the ERP Software to send some bill Information. Do you have some idea :) ? Thanks!



via Chebli Mohamed

How do I dynamically create a wordpress menu?

I have searched and searched and there is a post that shows that I can create pages and it has a spot to add the page to a menu. I would like to create a custom menu with parents and children. is this possible in word press.



via Chebli Mohamed

Remove and add actions in Wordpress using functions.php

I have edited some plugin files in wordpress but this is bad form - it stand up to updates. I'd like to make the changes using functions.php but I can't get it to work correctly.

The basics are that I want to remove the following actions:

add_action( 'woocommerce_before_my_account', array( $this, 'my_account_memberships' ) );

add_action( 'woocommerce_before_my_account', __CLASS__ . '::get_my_subscriptions_template' );

And in their place add the actions:

add_action( 'woocommerce_add_subscriptions_to_my_accoun', array( $this, 'my_account_memberships' ) );

add_action( 'woocommerce_add_subscriptions_to_my_account', __CLASS__ . '::get_my_subscriptions_template' );

I have tried adding the following (for both sets) to my functions.php but to no avail...

remove_action ( 'woocommerce_before_my_account', __CLASS__ . '::get_my_subscriptions_template' );

add_action( 'woocommerce_add_subscriptions_to_my_account', __CLASS__ . '::get_my_subscriptions_template' );

What am I doing wrong?



via Chebli Mohamed

how to show latest reviews on my homepage

I have a question and answer section on my website. I want to display the latest questions that people have posted in that section to appear on my homepage. An example would be how people display recent blog postings on the home page.

The questions and answer section is part of a wordpress plugin. Where as my website itself is a custom build.

Is there a simple code to grab the latest questions and post on the homepage?



via Chebli Mohamed

Featured image in WP Posts list (Backend)

Currently in Woocommerce i can see Product Thumbnail column in the posts (or products) lists in backend, see this example:

enter image description here

How i can get the thumbnail in column, but in Custom Posts Types? Without plugin

Excuse my english and in advance: Thanks :)



via Chebli Mohamed

How to decrease border height in ubermenu wordpress

Any idea how to decrease the height of this unnecessary border height? Ubermenu

I'm unable to decrease the height of that border under ubermenu control panel.

TOP ubermenu height

I tried to re-size the menu height using above entry, but it doesn't work for border height.



via Chebli Mohamed

WordPress - Get all of current page's queries information

Okay... so here is what I'm trying to do. Basically all of the components that make up any particular page on a Wordpress site, I need to be able to grab the query that WP is running to grab the data for that particular area of the given page. So, if we have page A, let's say it has a top navigation, main content section, and footer. Each of these three areas have content that is pulled from the database. I need a generic way to say on page X I want to know what queries have been ran to generate all of the content pulled from the database and displayed on the page.

I feel like the key is to properly use http://ift.tt/1xLY68I to get the data I need.

Any thoughts on how I could go about this?



via Chebli Mohamed

Background image wont show on the whole page

Hi i have a problem with my wordpress site - i used this css to change the background of page :

.page-id-689 #primary { background: url('http://ift.tt/1Z4CIYd') no-repeat center center !important;

-webkit-background-size: cover !important;

-moz-background-size: cover !important;

-o-background-size: cover !important;

background-size: cover !important;

min-height:100% !Important;

}


the problem is that the background wont show on the whole page ( Screenshot : http://ift.tt/1j0MDx4 ).

I already tried :

.page-id-287 #page_wrapper { height:100% !important; margin: 0px auto; }


html, body { height: 100% }


i also tried setting min-height to 100 % - wont work

!!! the problem is solved when i set the height to 1200px in #primary but it also causes huge problems in lower resolutions. Can someone help me with this ?



via Chebli Mohamed

How can I call a php / wordpress command from JavaScript?

I'm trying to create a lightbox effect for a self-made WordPress Theme. But I'm trying to include a WordPress page in the body through jQuery.

For example, in my js file.

    $('.button').Click(function(){

    $(body).append('`<div><?php get_template_part('content','thing'); ?></div>`');

});

I've tryed that and then my php file doesn't reproduce the php bit.

Thanks.



via Chebli Mohamed

Troubleshoot Codeigniter CLI stopped

I have been using the CLI interface to send out cron jobs from my codeigniter page. It worked fine until I updated Wordpress yesterday. I do not know how this effected Codeigniter but that is when the trouble started. I also installed cURL at about the same time. I am not sure if that could have made a difference.

SYMPTOMS: None of my codeigniter CLI scripts work. I have two scripts that send out email reminders, and another that synchronizes my database and none function.

ERRORS: I had some errors come up when I tried to run my scripts such as: Use of undefined constant DIR - assumed 'DIR'

This was never a problem before. But for now I change that to dirname(FILE) and that seemed to help. At least that error stopped.

Next another error notice appeared regarding code in my scripts that I was not getting before: "Can't use method return value in write context in . . ."

This error was in reference to this line of code:

if (!empty($this->get_available_hours($date, $provider_id))) {

I modified this to

$availabehours=$this->get_available_hours($date, $provider_id);
if (!empty($availabehours)) {

And the error stopped. But the script usually sends out email regarding availability and no email is sent.

Now I have no errors. I run the scripts and I get no results. If I purposefully mess with the code and do things wrong, I get the appropriate error messages. So, at some level it is reading the file.

I tried just running a simple "hello world file" as discribed here http://ift.tt/Y5erWB And nothing was returned.

I tried a simple email script that would send out an email without accessing my database and it did not send anything to me.

It appeares to me like something has caused my code to be interpreted in an older version of php. So I looked at the version currently running: PHP 5.2.17 (cli) (built: Feb 23 2012 10:42:34) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

This looks up to date.

MY QUESTION: What tests can I run to find out what is blocking things with my CLI? Any tips would be appreciated.



via Chebli Mohamed

Want to use pick-up and delivery date/time widget in wordpress site

I have a shopping cart setup on my website using woocommerce and all is set up perfectly What i want to achive there is to create a custom radio buttons to select the option for delivery/pickup. Is there any plugin which I can use to achieve the same? Can someone please help. Please note I am new to Wordpress and learning by online videos and ebooks.



via Chebli Mohamed

Make images private in Wordpress

I'm making a site, that I would like to make private. The most important part, is that the images on the domain can't be seen, without the user logging in first. So I would like all traffic to be redirected to http://ift.tt/1RrbBBI (also for images), if the user isn't logged in.

Here's what I've tried:

1) Plugins. I've tried both Wordpress Force Login , the plugin wp-require-login and a Coming soon page and Maintenance mode.

2) Adding a function from this answer. Which is this:

function is_login_page() {
    return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) );
}

function wpse_make_blog_private() {
    if ( ! is_user_logged_in() && ! is_admin() && ! is_login_page() ) { 
    global $wp_query;
    $wp_query->set_404();
    }
}
add_action( 'wp', 'wpse_make_blog_private' );

Non of these things redirects the traffic, if I go to the direct URL for the image (such as http://ift.tt/1Nh1z7r ).

Can that be done?

----------------- EDIT 1 --------------

Mevius pointed out, that Wordpress might not be loaded, if you type in the direct URL to an image, so he suggests, that it should be done on apache-level.

------------- END OF EDIT 1 -----------



via Chebli Mohamed

Display Excerpts of Posts in Wordpress Blog

I have been searching for the answer to my problem and I continually come up with replacing

<?php the_content(); ?>

with

<?php the_excerpt(); ?>

in the index.php file. However, the theme we are using does not contain this line. Anyone have any insight? Here is the code in our index.php file:

    <?php $t =& peTheme(); ?>
<?php $content =& $t->content; ?>
<?php $meta =& $content->meta(); ?>
<?php get_header(); ?>

<section class="section-blog section-index" id="<?php $content->slug(); ?>">

    <div class="row">
        <div class="large-12 columns text-center">

        </div>
    </div>

    <div class="row blog-main">

        <div class="large-9 columns blog-left">

            <?php $t->content->loop(); ?>

        </div>

        <?php get_sidebar(); ?>

    </div>

</section>

<?php get_footer(); ?>



via Chebli Mohamed

Wordpress, add post to custom taxonomy's category

I am trying to add a post to a category under taxonomy cate. The code I am using is:

$user = get_user_by( 'email', $_POST['user'] );
$id = array(
    'post_title'    => $_POST['title'],
    'post_content'  => $_POST['content'],
    'post_date'     => date('Y-m-d H:i:s'),
    'post_author'   => $user->ID,
    'taxonomy' => ('cate'),
    'post_type'     => 'ad',
    'post_category' => array(425),
    'post_status'   => 'publish',
); 
 $user_id = wp_insert_post($id);
if ( ! is_wp_error( $user_id ) ) {
   $odgovor["success"] = 1;

}

The post is added but it's added under category 'uncategorized" and not under desired category ID. This system works properly when custom post type is not used. (In this case taxonomy 'cate')

Any ideas?



via Chebli Mohamed

Want to use pick-up and delivery date/time widget in wordpress site

I have a shopping cart setup on my website using woocommerce and all is set up perfectly What i want to achive there is to create a custom radio buttons to select the option for delivery/pickup. Is there any plugin which I can use to achieve the same? Can someone please help. Please note I am new to Wordpress and learning by online videos and ebooks.



via Chebli Mohamed

jQuery load function or matchMedia or .css() function not working

Can someone please help and explain why the following code doesn't work? I can't seem to figure out why... to me, everything should be working.

jQuery(window).load(function($){
    if (window.matchMedia("(min-width: 768px)").matches) { 
        var sideHeight = $('.mainContent').css('height');
        $('.sidebar').css('height', sideHeight);
    }
});

Here is a jsfiddle of just the CSS part, which works. http://ift.tt/1LtH4nX

I've tested the media match part by putting an alert in that function, and I could get the alert to pop on window.load, but then the CSS code doesn't work. I've never been able to get the CSS code to run on my website and make my sidebar the same height as the main content. I put the js in the head, and at the end of the body. No change.

The site is built in WP. The content is loaded dynamically, so I thought it was doing the height before the content was loaded, but that's what the window.load() is supposed to fix, right?

Here is an article on the site you can check out. I want the sidebar to be the same height as the mainContent div so the gray background continues down the page. But only on tablet size and up (using bootstrap).

http://ift.tt/1hm4bCJ



via Chebli Mohamed

woocommerce order as guest not working

I am developing an ecommerce site with woo commerce, for my site i needed to include the register function on the same page on checkout. I did that but problem is if I put the register form, without registering I can not complete the order, i couldn't see any error info so cant figure it out what went wrong. here is my code:

<?php do_action('woocommerce_after_order_notes', $checkout); ?>
<?php if(!is_user_logged_in()) {?>
<input type="button" class="btn small red" name="button_address_continue"     value="<?php _e('Order As Guest', THB_THEME_NAME); ?>" />
<a id="register_form" class="btn red small" href="#">Register</a>

<div class="form-register" style="display: none;">
<form name="custom-register-checkout" class="custom-register-checkout" id="custom-register-checkout">
    <div class="registration-form woocommerce">
        <h2>Register</h2>
        <p class="form-row form-row-wide woocommerce-validated">
            <label for="reg_username">Username <span class="required">*</span></label>
            <input type="text" required="" class="input-text" name="username" id="reg_username" value="">
        </p>

        <p class="form-row form-row-wide">
            <label for="reg_password">Password <span class="required">*</span></label>
            <input type="password" required="" class="input-text" name="password" id="reg_password">
        </p>
        <!-- Spam Trap -->
        <div style="left: -999em; position: absolute;"><label for="trap">Anti-spam</label><input type="text" name="email_2" id="trap" tabindex="-1"></div>
        <p class="form-row">
            <input type="hidden" id="_wpnonce" name="_wpnonce" value="5f32d51264">
            <input type="hidden" name="_wp_http_referer" value="/checkout/">
            <input type="submit" id="custom-form-login" name="register" value="Register">
        </p>
    </div>
</form><!-- END .custom-register-checkout -->

and the jquery part

jQuery(document).ready(function($){
    $("#register_form").click(function() {
        $(".form-register").css("display","block");
        $("#order_review").css("display","none");
        return false;
    });
    var checkoutregister = $("#custom-register-checkout");
    checkoutregister.validate({
        rules: {
            username: {
                required: true
            },
            /*email: {
                required: true
            },*/
            password: {
                required: true
            }
        },
        messages: {
            username: "Please enter username",
            //email: "Please enter a email",
            password: "Please enter password"
        }
    });
    $("#custom-form-login").click(function() {
        var data = {
            'action': 'pd_checkout_register',
            'username': $("#reg_username").val(),
            //'email': $("#reg_email").val(),
            'password': $("#reg_password").val()
        };
        // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
        jQuery.post('<?php echo admin_url( 'admin-ajax.php' ); ?>', data, function (response) {
            var res = JSON.parse(response);
            if (res.status == 'ok') {
                window.location.reload();
            } else {
                alert(res.message);
            }
        });
        return false;
    });
});

problem is if I remove this form

<form name="custom-register-checkout" class="custom-register-checkout" id="custom-register-checkout">
    <div class="registration-form woocommerce">
        <h2>Register</h2>
        <p class="form-row form-row-wide woocommerce-validated">
            <label for="reg_username">Username <span class="required">*</span></label>
            <input type="text" required="" class="input-text" name="username" id="reg_username" value="">
        </p>

        <p class="form-row form-row-wide">
            <label for="reg_password">Password <span class="required">*</span></label>
            <input type="password" required="" class="input-text" name="password" id="reg_password">
        </p>
        <!-- Spam Trap -->
        <div style="left: -999em; position: absolute;"><label for="trap">Anti-spam</label><input type="text" name="email_2" id="trap" tabindex="-1"></div>
        <p class="form-row">
            <input type="hidden" id="_wpnonce" name="_wpnonce" value="5f32d51264">
            <input type="hidden" name="_wp_http_referer" value="/checkout/">
            <input type="submit" id="custom-form-login" name="register" value="Register">
        </p>
    </div>
</form>

I can place order as guest but if this form exists, I can not complete the order. Please help



via Chebli Mohamed

Make images private in Wordpress

I'm making a site, that I would like to make private. The most important part, is that the images on the domain can't be seen, without the user logging in first. So I would like all traffic to be redirected to http://ift.tt/1RrbBBI (also for images), if the user isn't logged in.

Here's what I've tried:

1) Plugins. I've tried both Wordpress Force Login , the plugin wp-require-login and a Coming soon page and Maintenance mode.

2) Adding a function from this answer. Which is this:

function is_login_page() {
    return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) );
}

function wpse_make_blog_private() {
    if ( ! is_user_logged_in() && ! is_admin() && ! is_login_page() ) { 
    global $wp_query;
    $wp_query->set_404();
    }
}
add_action( 'wp', 'wpse_make_blog_private' );

Non of these things redirects the traffic, if I go to the direct URL for the image (such as http://ift.tt/1Nh1z7r ).

Can that be done?

----------------- EDIT 1 --------------

Mevius pointed out, that Wordpress might not be loaded, if you type in the direct URL to an image, so he suggests, that it should be done on apache-level.

------------- END OF EDIT 1 -----------



via Chebli Mohamed

Unable to access server via bash or FTP

I created an entire website with wordpress on a server (serversfree.com) and the server seems to have basically died. I used to be able to FTP in, now I can't. Reset password no luck. The cPanel ssh console says "user not recognized. Unable to initiate policy plugin. Is there any way to get my wordpress site off?!



via Chebli Mohamed

Moving WordPress from Linux to Windows Server 2012 - database issue

I have been tasked with transferring a WordPress website from a test server (Linux server) to the client's own server (Windows 2012 server).

So far so good as I have transferred the files and created the new database to go with it. Also updated the wp-config.php file to include the new database info.

As per documentation I have read elsewhere, I changed the DB_HOST in the config file from 'localhost' to the IP address of the new server.

When I try to load the website I get the following error:

Notice: Use of undefined constant DB_HOST - assumed 'DB_HOST' in D:\inetpub\wwwroot\website\wp-includes\load.php on line 350 Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\inetpub\wwwroot\website\wp-includes\wp-db.php on line 1482 Warning: mysql_connect(): [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://DB_HOST:3306) in D:\inetpub\wwwroot\website\wp-includes\wp-db.php on line 1482 Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\inetpub\wwwroot\website\wp-includes\wp-db.php on line 1482

I can't make sense of it! Can anyone help?

I should mention that phpmyAdmin and mySQL are installed and apparently correctly set up on the Windows Server.

Thanks in advance!



via Chebli Mohamed

Browsers asking: Are you sure you want to leave this page?

When searching or going back on my website, the browsers brings up the alert: Are you sure you want to leave this page?

This only happens in Chrome and Mozilla.

The website is a wordpress.

I want to get rid of this because it is a terrible UI fault.

the website: http://ift.tt/1JOYhAD

Could it be a specific plugin or textbox?

There was no custom coding done on the website, besides CSS (which is only frontend)



via Chebli Mohamed

PHP Allocationg memory in WP does not work

I am runing a WP site and I am the root user of the VPS that is running right now.

So, when I am up to publish/create a new page it returns me the following message:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /home/.../public_html/wp-includes/compat.php on line 123

I have already search and read a various of articles about that problem. So I have done the following things:

From my whm -> php configs And I have allocate in memory_limit : 512M

Also, I have define at the top in wp-config.php file the following command:

define('WP_MEMORY_LIMIT', '512M');

However, I am still getting the error.

Additionally, I tried to insert the following in my .htaccess but it didn't work.

<IfModule mod_php5.c>
     php_value memory_limit 512M
</IfModule>

I have allocated more than 1GB but it didnt work.

Also, I have re-install the whole WP framework to the latest version.

Plus, I have restart the apache a couple of times to see the current setting on php, but i think that is not necessary. Right?

I have add the plugin: WP Overview (lite) to see the php allocation and I have that values:

Mem: WP 512M (def) Usage 16% 81.03M of PHP Limit 512M

Finally, I have created 2 test files to see the allocation:

File1:

<? phpinfo(); ?>

It returns that I have 512M php allocation which is correct.

File2: <?php echo memory_get_usage(); ?> which returns

213696

Is the this returning correct?? I thought that it should return 512M in bytes.. Right?

Any idea about the problem ? I am stacked on this issue.



via Chebli Mohamed

Google form embed into WordPress page-how to redirect after submission

I want to redirect user to a custom page on (ie. /thank-you) after he hits submit button within a google form that I embedded on my wordpress website

I found the answer to a similar question here but it looks like google forms were updated since this as I want to embed the form and it looks like this:

<iframe src="http://ift.tt/1LtH6vS" width="760" height="500" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>



via Chebli Mohamed

mapping cname to my custom domain name results in posts with cname only

I have a custom domain yourtechchick.com hosted with openshift. I have mapped Cname your-techchick.rhcloud.com to http://ift.tt/1hm4ehL and it seems to work. But, When I click on posts, It leads to url with http://ift.tt/1LtH4nO . I want it to be http://ift.tt/1hm4ehT. How do I fix this?

My permalink shows your-techchick.rhcloud.com option only. Is it possible to fix this with wordpress url and site url thing?

Also, I would like to know in detail the difference between wordpress url and site url.

I somewhere read this is where I need to change, if yes, which amongst these needs to be changed to http://ift.tt/1hm4ehL from http://ift.tt/1LtH6vO.

and In case I mess up these settings, which file will I need to reupload through ftp client in wordpress directory?



via Chebli Mohamed

WP Site Links Reverting to Former Subdomain

A few months ago, a coworker migrated two WordPress sites from subdomains to subdirectories. They were both fine at first, but after a few weeks, one of the sites crashed. Upon investigation, it was discovered that all of the site's urls in MySQL had been reverted to the former subdomain. The reverted urls crashed the site.

The database was restored from a backup copy and the site is back online, but it will occasionally (~ once per month) attempt to revert all of the urls back to the subdomain. I assume there must be a reference to the former subdomain stored somewhere. We have searched both the database and the site files for vestigial references to the former subdomain, but have not been able to find a single reference. We haven't been able to sift anything useful out of the error logs yet. There must a script in WordPress or elsewhere that is triggering the event.

So far, my best guess is dark magic. What else might be causing this issue?



via Chebli Mohamed

WordPress Plugin - Obtain output content without conflicts

I'm writing a WordPress plugin that obtain the HTML contents

i found 2 ways to obtain the final output:

// first way

function __myplugin_callback($buffer) {
    return $buffer;
}

function __myplugin_buffer_start() { ob_start("callback"); }

function __myplugin__buffer_end() { ob_end_flush(); }

add_action('wp_head', 'buffer_start');
add_action('wp_footer', 'buffer_end');

That works when i have only my plugin active, when i have more plugins active, like SEO Yoast, i get conflicts between plugins and mine is not working properly.

// second way
ob_start();

add_action('shutdown', function() {
$final = '';
$levels = ob_get_level();

for ($i = 0; $i < $levels; $i++)
{
    $final .= ob_get_clean();
}

echo apply_filters('final_output', $final);
}, 0);

// call the filter

add_filter('final_output', function($output)
{
     return str_replace(.., .., $output);
});

This works better than the first way but i have also conflicts with plugins like Visual Composer

There is a safe way, to obtain the final html output without conflicts with other plugins?



via Chebli Mohamed

How can I use htaccess to redirect paths with a wildcard character in wordpress

I recently changed my 92 category links and now I am getting hit with hundreds of 404 errors from Google because the old links are not found. I tried to use plugins to automatically redirect single URLS but I am noticing there are more and more coming in and doing everything on a 1 by 1 basis is not efficient.

I was hoping someone could assist me on getting my pages redirected using my htaccess file.

For Example Going to

http://ift.tt/1LtH47t

should redirect to

http://ift.tt/1hm4bCw

More importantly I would like to redirect the page numbers of the old categories to the page numbers of the new categories using a wildcard. So page x of old category will redirect to page x of new category.

http://ift.tt/1LtH4nG  

should redirect to

http://ift.tt/1hm4bCx

Thanks in advance.



via Chebli Mohamed

noUISlider typeerror: a is null

I am trying to add - noUISlider via a Wordpress plugin. But when adding nouislider.min.js file via enqueue script, I get following error -

TypeError: a is null

Here is the nouislider.min.js where error is occurring -

/*! nouislider - 8.0.2 - 2015-07-06 13:22:09 */

!function(a){if("function"==typeof define&&define.amd)define([],a);else if("object"==typeof exports){var b=require("fs");module.exports=a(),module.exports.css=function(){return b.readFileSync(__dirname+"/nouislider.min.css","utf8")}}else window.noUiSlider=a()}(function(){"use strict";function a(a){return a.filter(function(a){return this[a]?!1:this[a]=!0},{})}function b(a,b){return Math.round(a/b)*b}function c(a){var b=a.getBoundingClientRect(),c=a.ownerDocument,d=c.defaultView||c.parentWindow,e=c.documentElement,f=d.pageXOffset;return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(f=0),{top:b.top+d.pageYOffset-e.clientTop,left:b.left+f-e.clientLeft}}function d(a){return"number"==typeof a&&!isNaN(a)&&isFinite(a)}function e(a){var b=Math.pow(10,7);return Number((Math.round(a*b)/b).toFixed(7))}function f(a,b,c){j(a,b),setTimeout(function(){k(a,b)},c)}function g(a){return Math.max(Math.min(a,100),0)}function h(a){return Array.isArray(a)?a:[a]}function i(a){var b=a.split(".");return b.length>1?b[1].length:0}function j(a,b){a.classList?a.classList.add(b):a.className+=" "+b}function k(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp("(^|\\b)"+b.split(" ").join("|")+"(\\b|$)","gi")," ")}function l(a,b){a.classList?a.classList.contains(b):new RegExp("(^| )"+b+"( |$)","gi").test(a.className)}function m(a,b){return 100/(b-a)}function n(a,b){return 100*b/(a[1]-a[0])}function o(a,b){return n(a,a[0]<0?b+Math.abs(a[0]):b-a[0])}function p(a,b){return b*(a[1]-a[0])/100+a[0]}function q(a,b){for(var c=1;a>=b[c];)c+=1;return c}function r(a,b,c){if(c>=a.slice(-1)[0])return 100;var d,e,f,g,h=q(c,a);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],f+o([d,e],c)/m(f,g)}function s(a,b,c){if(c>=100)return a.slice(-1)[0];var d,e,f,g,h=q(c,b);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],p([d,e],(c-f)*m(f,g))}function t(a,c,d,e){if(100===e)return e;var f,g,h=q(e,a);return d?(f=a[h-1],g=a[h],e-f>(g-f)/2?g:f):c[h-1]?a[h-1]+b(e-a[h-1],c[h-1]):e}function u(a,b,c){var e;if("number"==typeof b&&(b=[b]),"[object Array]"!==Object.prototype.toString.call(b))throw new Error("noUiSlider: 'range' contains invalid value.");if(e="min"===a?0:"max"===a?100:parseFloat(a),!d(e)||!d(b[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");c.xPct.push(e),c.xVal.push(b[0]),e?c.xSteps.push(isNaN(b[1])?!1:b[1]):isNaN(b[1])||(c.xSteps[0]=b[1])}function v(a,b,c){return b?void(c.xSteps[a]=n([c.xVal[a],c.xVal[a+1]],b)/m(c.xPct[a],c.xPct[a+1])):!0}function w(a,b,c,d){this.xPct=[],this.xVal=[],this.xSteps=[d||!1],this.xNumSteps=[!1],this.snap=b,this.direction=c;var e,f=[];for(e in a)a.hasOwnProperty(e)&&f.push([a[e],e]);for(f.sort(function(a,b){return a[0]-b[0]}),e=0;e<f.length;e++)u(f[e][1],f[e][0],this);for(this.xNumSteps=this.xSteps.slice(0),e=0;e<this.xNumSteps.length;e++)v(e,this.xNumSteps[e],this)}function x(a,b){if(!d(b))throw new Error("noUiSlider: 'step' is not numeric.");a.singleStep=b}function y(a,b){if("object"!=typeof b||Array.isArray(b))throw new Error("noUiSlider: 'range' is not an object.");if(void 0===b.min||void 0===b.max)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");a.spectrum=new w(b,a.snap,a.dir,a.singleStep)}function z(a,b){if(b=h(b),!Array.isArray(b)||!b.length||b.length>2)throw new Error("noUiSlider: 'start' option is incorrect.");a.handles=b.length,a.start=b}function A(a,b){if(a.snap=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'snap' option must be a boolean.")}function B(a,b){if(a.animate=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'animate' option must be a boolean.")}function C(a,b){if("lower"===b&&1===a.handles)a.connect=1;else if("upper"===b&&1===a.handles)a.connect=2;else if(b===!0&&2===a.handles)a.connect=3;else{if(b!==!1)throw new Error("noUiSlider: 'connect' option doesn't match handle count.");a.connect=0}}function D(a,b){switch(b){case"horizontal":a.ort=0;break;case"vertical":a.ort=1;break;default:throw new Error("noUiSlider: 'orientation' option is invalid.")}}function E(a,b){if(!d(b))throw new Error("noUiSlider: 'margin' option must be numeric.");if(a.margin=a.spectrum.getMargin(b),!a.margin)throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.")}function F(a,b){if(!d(b))throw new Error("noUiSlider: 'limit' option must be numeric.");if(a.limit=a.spectrum.getMargin(b),!a.limit)throw new Error("noUiSlider: 'limit' option is only supported on linear sliders.")}function G(a,b){switch(b){case"ltr":a.dir=0;break;case"rtl":a.dir=1,a.connect=[0,2,1,3][a.connect];break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function H(a,b){if("string"!=typeof b)throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var c=b.indexOf("tap")>=0,d=b.indexOf("drag")>=0,e=b.indexOf("fixed")>=0,f=b.indexOf("snap")>=0;a.events={tap:c||f,drag:d,fixed:e,snap:f}}function I(a,b){if(a.format=b,"function"==typeof b.to&&"function"==typeof b.from)return!0;throw new Error("noUiSlider: 'format' requires 'to' and 'from' methods.")}function J(a){var b,c={margin:0,limit:0,animate:!0,format:U};b={step:{r:!1,t:x},start:{r:!0,t:z},connect:{r:!0,t:C},direction:{r:!0,t:G},snap:{r:!1,t:A},animate:{r:!1,t:B},range:{r:!0,t:y},orientation:{r:!1,t:D},margin:{r:!1,t:E},limit:{r:!1,t:F},behaviour:{r:!0,t:H},format:{r:!1,t:I}};var d={connect:!1,direction:"ltr",behaviour:"tap",orientation:"horizontal"};return Object.keys(d).forEach(function(b){void 0===a[b]&&(a[b]=d[b])}),Object.keys(b).forEach(function(d){var e=b[d];if(void 0===a[d]){if(e.r)throw new Error("noUiSlider: '"+d+"' is required.");return!0}e.t(c,a[d])}),c.pips=a.pips,c.style=c.ort?"top":"left",c}function K(a,b,c){var d=a+b[0],e=a+b[1];return c?(0>d&&(e+=Math.abs(d)),e>100&&(d-=e-100),[g(d),g(e)]):[d,e]}function L(a){a.preventDefault();var b,c,d=0===a.type.indexOf("touch"),e=0===a.type.indexOf("mouse"),f=0===a.type.indexOf("pointer"),g=a;return 0===a.type.indexOf("MSPointer")&&(f=!0),d&&(b=a.changedTouches[0].pageX,c=a.changedTouches[0].pageY),(e||f)&&(b=a.clientX+window.pageXOffset,c=a.clientY+window.pageYOffset),g.points=[b,c],g.cursor=e||f,g}function M(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=["-lower","-upper"];return a&&e.reverse(),j(d,T[3]),j(d,T[3]+e[b]),j(c,T[2]),c.appendChild(d),c}function N(a,b,c){switch(a){case 1:j(b,T[7]),j(c[0],T[6]);break;case 3:j(c[1],T[6]);case 2:j(c[0],T[7]);case 0:j(b,T[6])}}function O(a,b,c){var d,e=[];for(d=0;a>d;d+=1)e.push(c.appendChild(M(b,d)));return e}function P(a,b,c){j(c,T[0]),j(c,T[8+a]),j(c,T[4+b]);var d=document.createElement("div");return j(d,T[1]),c.appendChild(d),d}function Q(b,d){function e(a,b,c){if("range"===a||"steps"===a)return M.xVal;if("count"===a){var d,e=100/(b-1),f=0;for(b=[];(d=f++*e)<=100;)b.push(d);a="positions"}return"positions"===a?b.map(function(a){return M.fromStepping(c?M.getStep(a):a)}):"values"===a?c?b.map(function(a){return M.fromStepping(M.getStep(M.toStepping(a)))}):b:void 0}function m(b,c,d){var e=M.direction,f={},g=M.xVal[0],h=M.xVal[M.xVal.length-1],i=!1,j=!1,k=0;return M.direction=0,d=a(d.slice().sort(function(a,b){return a-b})),d[0]!==g&&(d.unshift(g),i=!0),d[d.length-1]!==h&&(d.push(h),j=!0),d.forEach(function(a,e){var g,h,l,m,n,o,p,q,r,s,t=a,u=d[e+1];if("steps"===c&&(g=M.xNumSteps[e]),g||(g=u-t),t!==!1&&void 0!==u)for(h=t;u>=h;h+=g){for(m=M.toStepping(h),n=m-k,q=n/b,r=Math.round(q),s=n/r,l=1;r>=l;l+=1)o=k+l*s,f[o.toFixed(5)]=["x",0];p=d.indexOf(h)>-1?1:"steps"===c?2:0,!e&&i&&(p=0),h===u&&j||(f[m.toFixed(5)]=[h,p]),k=m}}),M.direction=e,f}function n(a,b,c){function e(a){return["-normal","-large","-sub"][a]}function f(a,b,c){return'class="'+b+" "+b+"-"+h+" "+b+e(c[1])+'" style="'+d.style+": "+a+'%"'}function g(a,d){M.direction&&(a=100-a),d[1]=d[1]&&b?b(d[0],d[1]):d[1],i.innerHTML+="<div "+f(a,"noUi-marker",d)+"></div>",d[1]&&(i.innerHTML+="<div "+f(a,"noUi-value",d)+">"+c.to(d[0])+"</div>")}var h=["horizontal","vertical"][d.ort],i=document.createElement("div");return j(i,"noUi-pips"),j(i,"noUi-pips-"+h),Object.keys(a).forEach(function(b){g(b,a[b])}),i}function o(a){var b=a.mode,c=a.density||1,d=a.filter||!1,f=a.values||!1,g=a.stepped||!1,h=e(b,f,g),i=m(c,b,h),j=a.format||{to:Math.round};return I.appendChild(n(i,d,j))}function p(){return G["offset"+["Width","Height"][d.ort]]}function q(a,b){void 0!==b&&(b=Math.abs(b-d.dir)),Object.keys(R).forEach(function(c){var d=c.split(".")[0];a===d&&R[c].forEach(function(a){a(h(B()),b,r(Array.prototype.slice.call(Q)))})})}function r(a){return 1===a.length?a[0]:d.dir?a.reverse():a}function s(a,b,c,e){var f=function(b){return I.hasAttribute("disabled")?!1:l(I,T[14])?!1:(b=L(b),a===S.start&&void 0!==b.buttons&&b.buttons>1?!1:(b.calcPoint=b.points[d.ort],void c(b,e)))},g=[];return a.split(" ").forEach(function(a){b.addEventListener(a,f,!1),g.push([a,f])}),g}function t(a,b){var c,d,e=b.handles||H,f=!1,g=100*(a.calcPoint-b.start)/p(),h=e[0]===H[0]?0:1;if(c=K(g,b.positions,e.length>1),f=y(e[0],c[h],1===e.length),e.length>1){if(f=y(e[1],c[h?0:1],!1)||f)for(d=0;d<b.handles.length;d++)q("slide",d)}else f&&q("slide",h)}function u(a,b){var c=G.getElementsByClassName(T[15]),d=b.handles[0]===H[0]?0:1;c.length&&k(c[0],T[15]),a.cursor&&(document.body.style.cursor="",document.body.removeEventListener("selectstart",document.body.noUiListener));var e=document.documentElement;e.noUiListeners.forEach(function(a){e.removeEventListener(a[0],a[1])}),k(I,T[12]),q("set",d),q("change",d)}function v(a,b){var c=document.documentElement;if(1===b.handles.length&&(j(b.handles[0].children[0],T[15]),b.handles[0].hasAttribute("disabled")))return!1;a.stopPropagation();var d=s(S.move,c,t,{start:a.calcPoint,handles:b.handles,positions:[J[0],J[H.length-1]]}),e=s(S.end,c,u,{handles:b.handles});if(c.noUiListeners=d.concat(e),a.cursor){document.body.style.cursor=getComputedStyle(a.target).cursor,H.length>1&&j(I,T[12]);var f=function(){return!1};document.body.noUiListener=f,document.body.addEventListener("selectstart",f,!1)}}function w(a){var b,e,g=a.calcPoint,h=0;return a.stopPropagation(),H.forEach(function(a){h+=c(a)[d.style]}),b=h/2>g||1===H.length?0:1,g-=c(G)[d.style],e=100*g/p(),d.events.snap||f(I,T[14],300),H[b].hasAttribute("disabled")?!1:(y(H[b],e),q("slide",b),q("set",b),q("change",b),void(d.events.snap&&v(a,{handles:[H[h]]})))}function x(a){var b,c;if(!a.fixed)for(b=0;b<H.length;b+=1)s(S.start,H[b].children[0],v,{handles:[H[b]]});a.tap&&s(S.start,G,w,{handles:H}),a.drag&&(c=[G.getElementsByClassName(T[7])[0]],j(c[0],T[10]),a.fixed&&c.push(H[c[0]===H[0]?1:0].children[0]),c.forEach(function(a){s(S.start,a,v,{handles:H})}))}function y(a,b,c){var e=a!==H[0]?1:0,f=J[0]+d.margin,h=J[1]-d.margin,i=J[0]+d.limit,l=J[1]-d.limit;return H.length>1&&(b=e?Math.max(b,f):Math.min(b,h)),c!==!1&&d.limit&&H.length>1&&(b=e?Math.min(b,i):Math.max(b,l)),b=M.getStep(b),b=g(parseFloat(b.toFixed(7))),b===J[e]?!1:(a.style[d.style]=b+"%",a.previousSibling||(k(a,T[17]),b>50&&j(a,T[17])),J[e]=b,Q[e]=M.fromStepping(b),q("update",e),!0)}function z(a,b){var c,e,f;for(d.limit&&(a+=1),c=0;a>c;c+=1)e=c%2,f=b[e],null!==f&&f!==!1&&("number"==typeof f&&(f=String(f)),f=d.format.from(f),(f===!1||isNaN(f)||y(H[e],M.toStepping(f),c===3-d.dir)===!1)&&q("update",e))}function A(a){var b,c,e=h(a);for(d.dir&&d.handles>1&&e.reverse(),d.animate&&-1!==J[0]&&f(I,T[14],300),b=H.length>1?3:1,1===e.length&&(b=1),z(b,e),c=0;c<H.length;c++)q("set",c)}function B(){var a,b=[];for(a=0;a<d.handles;a+=1)b[a]=d.format.to(Q[a]);return r(b)}function C(){T.forEach(function(a){a&&k(I,a)}),I.innerHTML="",delete I.noUiSlider}function D(){var a=J.map(function(a,b){var c=M.getApplicableStep(a),d=i(String(c[2])),e=Q[b],f=100===a?null:c[2],g=Number((e-c[2]).toFixed(d)),h=0===a?null:g>=c[1]?c[2]:c[0]||!1;return[h,f]});return r(a)}function E(a,b){R[a]=R[a]||[],R[a].push(b),"update"===a.split(".")[0]&&H.forEach(function(a,b){q("update",b)})}function F(a){var b=a.split(".")[0],c=a.substring(b.length);Object.keys(R).forEach(function(a){var d=a.split(".")[0],e=a.substring(d.length);b&&b!==d||c&&c!==e||delete R[a]})}var G,H,I=b,J=[-1,-1],M=d.spectrum,Q=[],R={};if(I.noUiSlider)throw new Error("Slider was already initialized.");return G=P(d.dir,d.ort,I),H=O(d.handles,d.dir,G),N(d.connect,I,H),x(d.events),d.pips&&o(d.pips),{destroy:C,steps:D,on:E,off:F,get:B,set:A}}function R(a,b){if(!a.nodeName)throw new Error("noUiSlider.create requires a single element.");var c=J(b,a),d=Q(a,c);d.set(c.start),a.noUiSlider=d}var S=window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"},T=["noUi-target","noUi-base","noUi-origin","noUi-handle","noUi-horizontal","noUi-vertical","noUi-background","noUi-connect","noUi-ltr","noUi-rtl","noUi-dragable","","noUi-state-drag","","noUi-state-tap","noUi-active","","noUi-stacking"];w.prototype.getMargin=function(a){return 2===this.xPct.length?n(this.xVal,a):!1},w.prototype.toStepping=function(a){return a=r(this.xVal,this.xPct,a),this.direction&&(a=100-a),a},w.prototype.fromStepping=function(a){return this.direction&&(a=100-a),e(s(this.xVal,this.xPct,a))},w.prototype.getStep=function(a){return this.direction&&(a=100-a),a=t(this.xPct,this.xSteps,this.snap,a),this.direction&&(a=100-a),a},w.prototype.getApplicableStep=function(a){var b=q(a,this.xPct),c=100===a?2:1;return[this.xNumSteps[b-2],this.xVal[b-c],this.xNumSteps[b-c]]},w.prototype.convert=function(a){return this.getStep(this.toStepping(a))};var U={to:function(a){return a.toFixed(2)},from:Number};return{create:R}});



via Chebli Mohamed

ACF Repeater is not working on home page, same loop works fine on interior pages. Have tried several methods

So basically I'm trying to run a loop of /downloads/ (using Easy Digital Downloads) on my homepage. I'm attaching custom fields to each album and trying to loop through that separately. This has been way more difficult than I imagined. I tried several different looping methods, some have worked better than others. My current solution is so close.

I've tried different resets, using and not using Global $post, I originally was trying to use the Relationship or Post Object field, which I'd still like to do. I swapped it for just straight custom field data thinking that would solve it but still not working.

I recently pasted the same code in the single-download.php and it worked fine. I adjusted the Reading settings in WP back and forth, reset permalinks. Really confused whats holding this code up on the homepage?

Here is my current code:

<ul class="img-grid-4" id="releases">

    <?php //global $post;
    $args = array(
        'post_type'        => 'download',
        'posts_per_page'   => -1,
        'cat'               => -8,
        'order'            => 'ASC',
        'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ),
    );
    $custom_posts = new WP_Query($args);
    if ($custom_posts->have_posts()) :
        while( $custom_posts->have_posts()) :
            $custom_posts->the_post(); ?>


    <li>
        <a class="hook" href="<?php the_permalink(); ?>">
            <h5><?php the_title(); ?></h5>
            <?php if ( has_post_thumbnail() ) {
                the_post_thumbnail('full', array('class' => 'cover'));
            }  ?>
        </a>
        <section class="info">
            <h1><?php the_title(); ?></h1>
            <span class="close"><i class="icon-close"></i></span>
            <h6 class="price">Singles - $0.89 | Album - <?php echo get_post_meta( get_the_ID(), 'edd_price', true ); ?></h6>


    <?php if( have_rows('release_singles') ): ?>

        <ul class="tracks">
        <?php while( have_rows('release_singles') ): the_row(); 
            // vars
            $title = get_sub_field('title');
            $id = get_sub_field('cart_id');
            $link = get_sub_field('sample');
            ?>

            <li>
                <a href="" data-src="<?php echo $link; ?>" class="sm2_link">
                    <?php echo $title; ?>
                </a>
                <?php echo do_shortcode('[purchase_link class="button icon-cart" id="'. $id .'"]'); ?>       
            </li>

        <?php endwhile; ?>

        </ul>

    <?php endif; ?>



            <?php the_content(); ?>

            <a class="button" href="<?php the_permalink(); ?>">See Page</a>

            <?php echo do_shortcode('[purchase_link class="button"]'); ?>

            <footer class="entry-footer">
                <?php szymanskimusic_entry_footer(); ?>
            </footer><!-- .entry-footer -->
        </section>

    </li>

<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</ul>

Link to the demo site is here: http://ift.tt/1FSzq3S

If you click on the first album (orange with face on it) a modal pops up with the album info, plus a list of the repeater fields. The title and Cart buttons are correct, but clicking on the song link loads and plays the same mp3 for each of the list items.

If you click the See Page button at the bottom, you'll go to the single page, which has the same loop, and is working fine.

Code is also here: http://ift.tt/1LbFnF8

front-page-2 is currently what I'm using, and methods-tried.php are the various loop's I've tried to use.

$('#releases > li').on('click', '.hook', function(e){
        var $this = $(this);

        $this.removeAttr('href').parent().addClass('live');

        var $list = $this.siblings('.info').find('li');
        $list.each( function(){
            var $src = $(this).children('.sm2_link').data('src');
            $('.sm2_link').attr( 'href', $src );
        })
        soundManager.reboot();
        e.preventDefault();
    });



via Chebli Mohamed

How to use jQuery to load different images on specific pages in Wordpress

I'm newish to jQuery and hoping to use it primarily when working on Wordpress websites like this instance.

I am trying to load a unique logo on three specific portfolio pages. My aim is to use a unique class from each page and then add the image before a button with an ID of #scroll-down. Oddly, only the GPD_Logo_Colour1.gif shows up on all the pages. When I view the source code for the HTML markup I can see that jQuery loaded 2 of the three image with the GPD_Logo_Colour1.gif first, even though it is second in the jQuery code.

Do I have some incorrect syntax? or is the GPD_Logo_Colour1.gif cached? I'm really not sure where to look next for an answer. Thanks!

This is the code I've used in my functions.php file, in my child theme, to get the my.js file to be enqueued / load.

function evoc_child_script() {
wp_enqueue_script ('jquery');
wp_enqueue_script('jeremys javascript', 
get_stylesheet_directory_uri() . '/js/my.js', 
true);
}

add_action( 'wp_enqueue_scripts', 'evoc_child_script');

This the code in my my.js file

jQuery(document).ready(function(){

$('body.postid-239 #scroll-down' ).before('<img      src="http://ift.tt/1LtH3jQ"      />');

$('body.postid-192 #scroll-down' ).before('<img    src="http://ift.tt/1hm4e1o  content/uploads/2015/09/GPD_Logo_Colour1.gif" />');

$('body.postid-284 #scroll-down' ).before('<img src="http://ift.tt/1LtH3jR" />');

}); 



via Chebli Mohamed

javascript conflict with noUISlider in Wordpress plugin

Recently I got a problem with my Wordpress plugin. I am trying to integrate noUISlider - http://ift.tt/1hm4bmh via the plugin.

I was trying to add the slider through a shortcode. Everything goes well, I can add the shortcode to a page and the slider works what should it do. But when i go another page(except shortcode page) i get some javascript error - TypeError: a is null in nouislider.min.js.

Can anyone please suggest me how can i solve it?

Thanks in advance.



via Chebli Mohamed

How can I upload multiple items using Contact Form 7 in my wordpress woocommerce site

Here is what I want to achieved: User click here to add another item

Here is my form Settings:

<p>Your Name (required)<br />
[text* your-name default:user_login] </p>

<p>Your Address<br />
[textarea your-message] </p>

<p>Your Phone (required)<br />
[text* your-phone] </p>

<p>Your Email (required)<br />
[email* your-email default:user_email] </p>

<p>Description of item<br />
[textarea item-desc] </p>

<p>Location of item<br />
[text item-location] </p>

<p>Photo of Item<br />
[file photo id:item-photo]</p>


<p>[submit "Submit"]</p>

Once a user click submit, I want the message displayed : Click here to add (as shown in the screenshot above) another item. This means, the customer can continue to add other items. However, I want the form to remember all other details the customer inputted so the customer will just add Photo of Item, Location of item and description of item. Every customer can add maximum of 10 items for a form submission. I will appreciate any help with this. If you have a cleaner way of achieving this, I will appreciate the advise. All I want is a customer can fill his biodata and can upload maximum of 10 items with description, location and photo of each item. Thank you for always.



via Chebli Mohamed

mysql_num_rows() error when processing script

I am adding a custom validation page to a WordPress Website I am working on.

Here is how the steps work to get a better understanding of the functional need.

  1. visitor comes to the site and trys to sign up
  2. visitor arrives to membership verification (this page will be a simple form with 3 fields that the user must enter their information as it appears on their membership card number.)
  3. If incorrect info is provided the visitor receives an error message. If they enter successful information they will be redirected to the actual registration page of the WordPress website.

The issue.

I have built all my forms and everything is working except the validation process. Here is the script I am using

<?php
$error=''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['int_no']) || empty($_POST['firstnames']) || empty($_POST['surname'])) {
$error = "It appears that you have forgotten to fill out one of the form fields. Please fill out all requested information and try again.";
}
else
{
// Define $int_no $firstnames and $surname
$int_no=$_POST['int_no'];
$firstnames=$_POST['firstnames'];
$surname=$_POST['surname'];
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysql_connect("localhost", "username", "password");
// To protect MySQL injection for Security purpose
$int_no = stripslashes($int_no);
$firstnames = stripslashes($firstnames);
$surname = stripslashes($surname);
$int_no = mysql_real_escape_string($int_no);
$firstnames = mysql_real_escape_string($firstnames);
$surname = mysql_real_escape_string($surname);
// Selecting Database
$db = mysql_select_db("IUEC-MEMBERS", $connection);
// SQL query to fetch information of registered Union Members and finds if there is a match.
$query = mysql_query("select * from login where surname='$surname' AND firstnames='$firstnames' AND int_no='$int_no'", $connection);
$rows = mysql_num_rows($query);
if ($rows == 1) {
$_SESSION['login_user']=$int_no; // Initializing Session
header("location: http://ift.tt/1L1Y277"); // Redirecting To Other Page
} else {
$error = "We were not able to verify the information you provided. Please ensure you are entering your information as it appears on your International Card. If you continue to have issues please contact your Local.";
}
mysql_close($connection); // Closing Connection
}
}
?>

I am getting an error when I enter the information and select the submit button.

The website URL in question is http://ift.tt/1L1Y4fu

I am turing to the gurus that are within this site in hopes that you can shine some light on this issue.

Thank you all for your assistance.



via Chebli Mohamed

How get all taxonomy values for each woocommerce product in MySQL [on hold]

I have more than 600 products in my woocommerce plugin. I've exported all my wordpress database in SQL.

I want to get all the taxonomy values of my Woocommerce product page.

How can I, in mySQL, retrieve all the taxonomy values for all my product page ?

For exemple :

Product id = "15282" and all the taxonomies like : Country = "Spain"| City = "Madrid" | Price = "300" etc... ?

Thank you a lot :)



via Chebli Mohamed

WordPress pagination not working with excluded posts

I'm using an array inside WP_Query, this is for the index.php page. The code is like so

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    $args = new WP_Query( array(
       'post__not_in'       => $exclude_ids, // This works correctly
       'paged'              => $paged,
       'posts_per_page'     => 9, // I added this as a hope but didn't work
    ) );

$the_query = new WP_Query( $args ); ?>



<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

but the paged is not working. I echod took the $paged out and it is doing 1,2,3 like it should (I'm assuming?) so it that part is working, and the URL is changing and the pagination link recognises it's on page 1,2,3 but the posts are all the same.



via Chebli Mohamed

Parse error unexpected '{' [duplicate]

This question already has an answer here:

I'm struggling with my website which doesn't want to open anymore. After a complete re-upload of wordpress I get this error :

Parse error: syntax error, unexpected '{' in /home/orchestrw/www/wp-includes/functions.php on line 2678

Here are the few lines :

        if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )  {
        return $json;
    }

    try {
        $args[0] = _wp_json_sanity_check( $data, $depth );
    } catch ( Exception $e ) {
        return false;
    }
{
    return call_user_func_array( 'json_encode', $args );
}

The line 2678 is "try {" Thanks for your help Jean

The complete code is too big to post here, I've added a few lines from higher up

    function wp_json_encode( $data, $options = 0, $depth = 512 ) {
    /*
     * json_encode() has had extra params added over the years.
     * $options was added in 5.3, and $depth in 5.5.
     * We need to make sure we call it with the correct arguments.
     */
    if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
        $args = array( $data, $options, $depth );
    } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
        $args = array( $data, $options );
    } else {
        $args = array( $data );
    }

    $json = call_user_func_array( 'json_encode', $args );

    // If json_encode() was successful, no need to do more sanity checking.
    // ... unless we're in an old version of PHP, and json_encode() returned
    // a string containing 'null'. Then we need to do more sanity checking.
    if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )   {
        return $json;
    }

    try {
        $args[0] = _wp_json_sanity_check( $data, $depth );
    } catch ( Exception $e ) {
        return false;
    }
{
    return call_user_func_array( 'json_encode', $args );
}



via Chebli Mohamed

How to change my site url structure in .htaccess

My current page-url looks like the below,

http://localhost/testWP/?mode=home

but I want to make the url like the following:

http://localhost/testWP/mode/home


  • How do I write an appropriate .htaccess-file to turn this into reality?


via Chebli Mohamed

wordpress hacked - posts created and added hidden html

I noticed that a website of my client has been hacked. I found a new user that created a lot posts. Also I noticed that in the main pages, he wrote some text, but he made this content hidden with a position absolute and a top and left propriety very high. now, what are the best steps to make the website safe? I can delete delete all this content, but I think that this hacker can create again this content as the first time. so, what can I do? Any suggestion?



via Chebli Mohamed

TypeError: target is null in noUISLider

I am using noUISlider - http://ift.tt/x3H9Pe . When adding the slider nouislider.js via enqueue script in Wordpress i get following javascript error in firebug -

TypeError: target is null

if ( !target.nodeName ) {

Here i how enqueued the script -

wp_register_script('realstate-noui', BRPC_BASE_URL . 'js/nouislider.js');
wp_enqueue_script('realstate-noui');

The code of nouislider.js where error is happening -

function initialize ( target, originalOptions ) {

                if ( !target.nodeName ) {
                        throw new Error('noUiSlider.create requires a single element.');
                }

                // Test the options and create the slider environment;
                var options = testOptions( originalOptions, target ),
                        slider = closure( target, options );

                // Use the public value method to set the start values.
                slider.set(options.start);

                target.noUiSlider = slider;
        }

        // Use an object instead of a function for future expansibility;
        return {
                create: initialize
        };


via Chebli Mohamed

why menubar is hiding in wordpress admin

i am working on wordpress where the user has diffrent but after the user login with role subscriber all menus of admin are hiding which should not hide . it should work as usual.how to solve this issue . i want all my menu to appear. before it was redirecting to profile.php .then i made changes in wp-login.php

$redirect_to = user_admin_url();

my idea is, user with all role will be redirect to same page ie wp-admin page .then according to user role remove menu from dashboard by using remove_menu_page



via Chebli Mohamed

Order page listing by postdate desc

I had made gallery with a tumbnails with wordpress but I have a little problem on it. All my gallerys are wordpress classic pages , which are child pages of (editorial,personal,fashioned - one of them) . And this parent pages(editorial,personal,fashion) are child of PHOTOGRAPHY page. When I'm listing my thumbnails it is first listing ALL EDITORIAL PAGES,AFTER ALL PERSONAL,AND AFTER ALL FASHION BUT NOT THE LAST ADDED ITEM. I need to mix the results by date to display correctly latest item , not separated results like now. I'll show what I have maybe somebody have any ideas...Also I'll attach little screenshot to make my question more clear. Also there is another way to solve this problem just to list PHOTOGRAPHY parent page(contains childs 403,414,417) but in this case i need to exclude this 3 parent pages from listing but keep their child pages. I'm noob in coding so will be happy for any qnaswer ^ THANKS

WHAT I HAVE

<div class="base-content">

<div id="archive-thumbnails-listing" >
<?php $pages = array();
foreach (array(403, 414, 417) as $id) {
$pages = array_merge($pages, get_pages(array('child_of' => $id ,'sort_column' => 'post_date', 'sort_order' => 'desc' )));
} ?>
<?php foreach ($pages as $page): ?>
<div class="thumb12wrap"> 
<a href="<?php echo get_the_permalink($page->ID); ?>"> 
<?php echo get_the_post_thumbnail($page->ID, 'full'); ?></a> 
<div class="thumbwrapper88"> 
<div class="shade23desc" ><a class="desc" href="<?php echo get_the_permalink($page->ID); ?>"><?php echo $page->post_title; ?></a></div> 
<a class="descarea" href="<?php echo get_the_permalink($page->ID); ?>"></a> 
</div>
</div>   
<?php endforeach; ?>
</div>
<div style="float:left;height:50px;width:100%;position:relative;"></div>
</div>

this 403 is editorial(parent page) , 414 (personal parent page) 414 (fashion parent page)

http://ift.tt/1LtH3QL IMAGE



via Chebli Mohamed

How to move a map using Map press easy Google plugins

I'm currently building a website using wordpress. I used Map press easy Google plugins for include a map in my contact tab. However, I want to put for example the map to the left and a form to the right. But I don't find any features which can allow me to move it. I tried to use the .css file but I don't have any html take to select. Here is my website with my map:

http://ift.tt/1hm48qp

and here's the code provide by the plugin that I insert into my contact page:

[mappress mapid="1"]

Does who is using this plugin can help me ? Thank's



via Chebli Mohamed

Skip the Order page in Woocommerc

I have a site and I want the one page checkout site. alphamaxis.com this is my site when I have click on the Rush my Order then I have one more step on which step order id generating. But I want that when user click on home page Rush my order button then it redirect to checkout page. On home page I am using contact form and storing all the value into session and then use user information for billing address. Hope this make sense.

Following code I am using:

$_SESSION['rnd_user']=$_POST;
$product_id = 209;
$woocommerce->cart->empty_cart();
if ($woocommerce->cart->get_cart_contents_count() == 0) {
    $woocommerce->cart->add_to_cart($product_id);
}
wp_redirect($_POST['success_url']);

hope this make sense. Any help will appreciate. Thanks in advance . Looking forward for your positive and quick reply.



via Chebli Mohamed

Invalid Signature - provided signature does not match WooCommerce REST API calling from Android

Please Don't downvote without comment.

I am an Android developer and new to woocommerce and started consuming REST service with Oauth1.0 authentication.I am getting proper response from PostMan (RestClient plugin) and getting "Invalid Signature" error while I call from my android application.

Here is my Android Code:

    OAuthParameters oauth;

    public OAuthParameters authChecking() {
        oauth = new OAuthParameters();
        GenericUrl genericUrl = new GenericUrl("http://localhost/wordpress/wc-api/v3/products/count");

        oauth.consumerKey = "ck_xxxxxxxxxxxxxxxxxxxxxxxxxxx";
        oauth.signatureMethod = "HMAC-SHA1";
        oauth.version = "3.0";
        oauth.computeTimestamp();
        oauth.computeNonce();

        oauth.signer = new OAuthSigner() {
            @Override
            public String getSignatureMethod() {

                return oauth.signatureMethod;
            }

            @Override
            public String computeSignature(String signatureBaseString) throws GeneralSecurityException {

                String key = "cs_xxxxxxxxxxxxxxxxxxxxxxxxxx";

                Mac mac = Mac.getInstance(
                        "HmacSHA1");
                SecretKeySpec secret = new SecretKeySpec(key.getBytes(), "HmacSHA1");

                mac.init(secret);
                byte[] digest = mac.doFinal(signatureBaseString.getBytes());
                Log.e("SIGNATURE Base64", new String(Base64.encode(digest, 0)).trim());

                String signature = new String(com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64.encodeBase64String(digest));
                return signature;
            }
        };
        try {
            oauth.computeSignature("GET", genericUrl);

        } catch (GeneralSecurityException e) {
            e.printStackTrace();
            return null;
        } catch (NullPointerException e) {
            e.printStackTrace();
            return null;
        }
        methodSignatureTest();
        return oauth;
    }


 @Override
    public void requestAPI(Object... param) {
        OAuthParameters oauth = authChecking();
        if (oauth != null) {
            String url = null;
            try {

                Toast.makeText(MainActivity.this, "Signature retrive called", Toast.LENGTH_SHORT).show();
                url = "http://localhost/wordpress/wc-api/v3/products/"+"count?oauth_consumer_key=" + oauth.consumerKey + "&oauth_signature_method=" + oauth.signatureMethod + "&oauth_timestamp=" + oauth.timestamp + "&oauth_nonce=" + oauth.nonce + "&oauth_version=" + oauth.version + "&oauth_signature="
//               + java.net.URLDecoder.decode(oauth.signature, "UTF-8");
                        + URLEncoder.encode(oauth.signature, "UTF-8");
//            +oauth.signature;
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                url = null;
            }
            Log.v("URL ", url);
            Log.v("SINGNATURE ", oauth.signature);

            getDataFromWeb_Get.getData(this, this, new String[]{"http://localhost/wordpress/wc-api/v3/products/", url});

        }
    }

I have searched on google for generating Signature but all were saying the same code. I use this tool http://ift.tt/1jVJ6e6 to validate signature but could not validate because PostMan, this tool and android generated signature were different from each other.

Kindly help me to get out of it. I have searched for 2 days and did not get any result.



via Chebli Mohamed

How to get Apposite action of remove_menu_page();

I want to add a customoize menu link in wordpress admin menubar .i want exactly opposite action of remove_menu_page( 'plugins.php' ); .As remove_menu_page() removes required link from menubar . i want to add required menu to admin menubar . is it possible through function.php



via Chebli Mohamed

Enable CORS - how to do this right

So. I have a site based on wordpress where I use WPMl for translation. Domain1 is my base domain - and then I point my domain2 DNS to domain1 where its parked. In WPML I set it to listen to domain2 for my second language.

Problem? It wont load my custom fonts for the second domain.

Error: Font from origin 'http://domain1' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://domain2' is therefore not allowed access.

I have tried to enable CORS via my .htacces with

header("Access-Control-Allow-Origin: * 

and I tried to add it via php with:

<?php /** @package WordPress @subpackage Default_Theme  **/
header("Access-Control-Allow-Origin: *"); 
?>

Nothing seems to work. what am I doing wrong?



via Chebli Mohamed

nwoocommerce hide specific states based on product catogery

I have a issue with my woocommerce site .

I want to hide all states but one when customers selects a specific category product. what i want to do is not allow a specific category product to be bought by other sates person.

for example I have 2 category dry fish, fresh fish . I want all states of a county be able to shop 'dry fish' category product but not allow 'fresh fish' category to be bought out side the state.

Any help would be highly appreciated .



via Chebli Mohamed

WP Plugin for product display with categories

Can anyone suggest me a wordpress plugin that can be used for showcase products with categories... Please help me with this...

-Thanks



via Chebli Mohamed

How to Fix memory leak in Wordpress?

My server is running HHVM.

Everything is working almost fine, except on thing. Because of memory leaks the Translation Cache gets filled up, and once it is almost full the HHVM can not render the pages anymore so every user only would see a blank page instead of the article.

To prvent this from happening it is necessary that all create_function calls get replaced by anonymous functions. See (for more info):

http://ift.tt/1jJNWRO

and the docs of hhvm which also say to use anonymous functions:

http://ift.tt/1VAxvmu

So my question now is how do I replace the create function calls which are made in the translation.php and the po.php with anonymous functions?



via Chebli Mohamed

Getting error in an woocommerce based store. WP is not defined in meta boxes variations.php

I have a woocommerce based online store with around 70 products. Everything was working fine till yesterday, today I am getting these javascript errors

  1. WP is not defined in meta boxes variations.php in product list page. (causing the list of products is not displaying in backend. Its there in db I checked.)

  2. woocommerce_params not defined.(Causing plugin list not displaying but that is solved for now.)

No theme up-gradation, no woocommerce up-gradation not even wordpress. Nothing is happened.

Can anybody tell what might be the issue? I have WordPress 4.0.8 and woocommerce 2.3

Thanks in advance.



via Chebli Mohamed

Custom featured image as header on blog page

I have created a page called 'News', which I'm using as the blog page. I have inserted an image as featured image in the header (set as background image), but what is displayed there is the featured image of the very last blog post. How can I force WordPress to use the featured image of that specific page instead of a thumbnail from the blog post?



via Chebli Mohamed

Getting error in an woocommerce based store. WP is not defined in meta boxes variations.php

I have a woocommerce based online store with around 70 products. Everything was working fine till yesterday, today I am getting these javascript errors

  1. WP is not defined in meta boxes variations.php in product list page. (causing the list of products is not displaying in backend. Its there in db I checked.)

  2. woocommerce_params not defined.(Causing plugin list not displaying but that is solved for now.)

No theme up-gradation, no woocommerce up-gradation not even wordpress. Nothing is happened.

Can anybody tell what might be the issue? I have WordPress 4.0.8 and woocommerce 2.3

Thanks in advance.



via Chebli Mohamed

How to track exit links

I have a website with embedded videos. Each iframe comes from different website. The problem is that some of them, are redirecting my visitors to their assigned destination without actions (click, hover, etc). And now Google is listing my website as suspicious. Is there any php script to track every single exit link from my pages to another website? Let's say i'm using Wordpress and have already created $table_name tracking 1-timestamp, 2-my page that was redirected, and 3-the destination of the external website/domain.

function the_function() {
// if there is any function
}

if ( the_function() == true // or false )
{
$wpdb->insert($table_name, array(
'timestamp' => $timestamp,
'page' => $my_page_redirected_to_a_different_domain,
'destination'=> $destination,
));
}

Or if there is any js script, no problem



via Chebli Mohamed

how to access plugin page from link in admin menu.php of wordpress

i have written admin_url('admin.php?page=camp_create') in menu.php of wordpress to create a link which will redirect to plugin page. after clicking it it is giving an error

You do not have sufficient permissions to access this page.

link

 $menu[71] = array( __('Campaign'), 'read', admin_url('admin.php?page=camp_create'), '', 'menu-top menu-icon-users', 'menu-users', 'dashicons-admin-users' );

i want to access plugin page but an error occurs

You do not have sufficient permissions to access this page.



via Chebli Mohamed

Show body content with popup in Wordpress

$large_image    = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');

$output .= '<a class="overlay" rel="shadowbox" href="'.$large_image[0].'">';

It's OK, working fine.

But I want, show post's body in popup. I tried like this but not working.

   $content     = wp_get_attachment_image_src( body($post->ID));

Whats the problem? How can I fix it? Thanks.



via Chebli Mohamed

How to improve page load performance of the Wordpress website?

I am creating web portal in wordpress for that I am using i-craft theme. But my website page loading very slow at initial load that is before loading of all content. Its taking 8 - 10 sec to initial load. I know this is happening due to lots php code with lots of functions and loops.
I want to remove all unnecessary code or php file. As my website belongs to only single theme and I don't want to add post functionality etc. so which file/php code/information in database I have to remove that will helps website to load initially faster. Or is there any way to make loading very fast without removing code or files.



via Chebli Mohamed

Make code snippet into a foreach loop

I have a piece of code which is used to replace double dashes for commas in a wordpress taxonomy called “authors” before displaying values to the end user.

This is working great, but now I need to apply it to several different taxonomies, no just “authors” but also “printers”, “translators”, etc.

My idea was to build an array of taxonomies instead of a single variable and then use a foreach loop to apply the find and replace to each of them, but no matter how I try it I can’t seem to make it work…

Any idea how to make the following code into a foreach loop if $custom_taxonomy_type was an array?

This is the code that is currently working for a single taxonomy.

if(!is_admin()){ // make sure the filters are only called in the frontend

$custom_taxonomy_type = 'authors';  // here goes your taxonomy type

function comma_taxonomy_filter($tag_arr){
    global $custom_taxonomy_type;
    $tag_arr_new = $tag_arr;
    if($tag_arr->taxonomy == $custom_taxonomy_type && strpos($tag_arr->name, '--')){
        $tag_arr_new->name = str_replace('--',', ',$tag_arr->name);
    }
    return $tag_arr_new;    
}
add_filter('get_authors', comma_taxonomy_filter);

function comma_taxonomies_filter($tags_arr){
    $tags_arr_new = array();
    foreach($tags_arr as $tag_arr){
        $tags_arr_new[] = comma_taxonomy_filter($tag_arr);
    }
    return $tags_arr_new;
}
add_filter('get_the_taxonomies',    comma_taxonomies_filter);
add_filter('get_terms',             comma_taxonomies_filter);
add_filter('get_the_terms',         comma_taxonomies_filter);

}

As requested by @Epodax here are the two things I've tried so far. Both result in a blank page:

if(!is_admin()){ // make sure the filters are only called in the frontend

    $custom_taxonomy_type_array = array('authors', 'printer');  // here goes your taxonomy type

    foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
        function comma_taxonomy_filter($tag_arr){
            global $custom_taxonomy_type;
            $tag_arr_new = $tag_arr;
            if($tag_arr->taxonomy == $custom_taxonomy_type && strpos($tag_arr->name, '--')){
                $tag_arr_new->name = str_replace('--',', ',$tag_arr->name);
            }
            return $tag_arr_new;    
        }
        add_filter('get_'.$custom_taxonomy_type, comma_taxonomy_filter);

        function comma_taxonomies_filter($tags_arr){
            $tags_arr_new = array();
            foreach($tags_arr as $tag_arr){
                $tags_arr_new[] = comma_taxonomy_filter($tag_arr);
            }
            return $tags_arr_new;
        }
        add_filter('get_the_taxonomies',    comma_taxonomies_filter);
        add_filter('get_terms',             comma_taxonomies_filter);
        add_filter('get_the_terms',         comma_taxonomies_filter);
    }


}

and

if(!is_admin()){ // make sure the filters are only called in the frontend

    $custom_taxonomy_type_array = array('authors', 'printer');  // here goes your taxonomy type

    function comma_taxonomy_filter($tag_arr){
        foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
            global $custom_taxonomy_type;
            $tag_arr_new = $tag_arr;
            if($tag_arr->taxonomy == $custom_taxonomy_type && strpos($tag_arr->name, '--')){
                $tag_arr_new->name = str_replace('--',', ',$tag_arr->name);
            }
            return $tag_arr_new;    
        }
    }
    foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
        add_filter('get_'.$custom_taxonomy_type, comma_taxonomy_filter);
    }

    function comma_taxonomies_filter($tags_arr){
        foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
            $tags_arr_new = array();
            foreach($tags_arr as $tag_arr){
                $tags_arr_new[] = comma_taxonomy_filter($tag_arr);
            }
            return $tags_arr_new;
        }
    }
    foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
        add_filter('get_the_taxonomies',    comma_taxonomies_filter);
        add_filter('get_terms',             comma_taxonomies_filter);
        add_filter('get_the_terms',         comma_taxonomies_filter);
    }

}



via Chebli Mohamed

Order wordpress comments in descending order and provide a toggle to switch to ascending order

My wordpress comments now are in ascending order. I wanted to display it by default in descending order.I have done this via admin panel by going to Settings->Discussion.

But now I want to provide an option to the user so that he can toggle this ordering if he needs. That is, by default comments would be in descending order of date but if the user wants he can view the comments in ascending order at the click of maybe a link or button. Is this possible?

I am using Greg's threaded comments to display my comment section.



via Chebli Mohamed

wp_new_user_notification() conflict

I'm using the following to change notification emails when a new user registers

<?php
/*
Plugin Name: Custom New User Email
Description: Changes the copy in the email sent out to new users
*/

// Redefine user notification function
if ( !function_exists('wp_new_user_notification') ) {
function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
    $user = new WP_User($user_id);

    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);
    $user_name = stripslashes($user->user_nicename);
    $user_phone = stripslashes($user->user_phone);


    $message  = sprintf(__('New user registration on your site %s:'), get_option('blogname')) . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n\r\n";
    $message .= sprintf(__('Name: %s'), $user_name) . "\r\n\r\n";
    $message .= sprintf(__('Phone: %s'), $user_phone) . "\r\n";

    $multiple_recipients = array(
       'email@mail.com',
       get_option('admin_email')
    );

    @wp_mail($multiple_recipients, sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);

    if ( empty($plaintext_pass) )
        return;

    $message  = __('Hello,') . "\r\n\r\n";
    $message .= sprintf(__("Welcome to The Business Connection. Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
    $message .= wp_login_url() . "\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
    $message .= sprintf(__('If you have any problems, please contact us at %s.'), get_option('admin_email')) . "\r\n";


    wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);

}
}

?>

The mail is leaving the web server fine but isn't arriving to the inbox.

Any thoughts/suggestions as to why or how to go about debugging.

Tested with this and it's all good http://ift.tt/1XVitvv



via Chebli Mohamed

How do I hide date in Google snippet using PHP?

I want to hide the date in my Google snippet and I currently use Yoast SEO plugin. I couldn't change there so I thought I could change it myself. I notice you have the 'the_date' function in 9 matches across 7 files. However, I thought I can use Javascript instead of PHP.

<?php the_time('F jS, Y') ?>

I can replace with,

<script language="javascript"
type="text/javascript">document.write("<?php the_time('F jS, Y')
?>");</script>

Google does not use javascript when pulling data for the description. So it will display for the user but not read by Google.

I could do these in the free themes but am unable to find the required function. I am not sure what to replace with what.

In my files, I can only see,

C:\wamp\www\wp-content\themes\TheDefensionem\cover.php:
   52  // Day
   53  if( is_day() ){
   54:  $title = get_the_date();
   55   $title_above = __('Daily Archives', 'brook');
   56  }
   ..
   58  // Month
   59  if( is_month() ){
   60:  $title = get_the_date( _x( 'F Y', 'monthly archives date format', 'brook' ) );
   61   $title_above = __('Monthly Archives', 'brook');
   62  }
   ..
   64  // Year
   65  if( is_year() ){
   66:  $title = get_the_date( _x( 'Y', 'yearly archives date format', 'brook' ) );
   67   $title_above = __('Yearly Archives', 'brook');
   68  }

C:\wamp\www\wp-content\themes\TheDefensionem\infobar.php:
   29               <div class="meta--items fl">
   30                   <div class="meta--item meta--date">
   31:                      <?php echo get_the_date(); ?>
   32                   </div>
   33               </div>

C:\wamp\www\wp-content\themes\TheDefensionem\loop_item-grid_gallery.php:
   84               <div class="meta--items">
   85                   <div class="meta--item meta--date">
   86:                      <?php echo get_the_date(); ?>
   87                   </div>
   88  

C:\wamp\www\wp-content\themes\TheDefensionem\loop_item-list_archive.php:
   66  
   67               <div class="meta--item meta--date">
   68:                  <?php echo get_the_date(); ?>
   69               </div>
   70  

C:\wamp\www\wp-content\themes\TheDefensionem\loop_item-widget_list.php:
   19  
   20           <div class="meta--item meta--date">
   21:              <?php echo get_the_date(); ?>
   22           </div>
   23  

C:\wamp\www\wp-content\themes\TheDefensionem\post_meta.php:
    2  
    3   <div class="meta--item meta--date">
    4:      <?php echo get_the_date(); ?>
    5   </div>
    6  

C:\wamp\www\wp-content\themes\TheDefensionem\related_posts.php:
   59  
   60               <div class="meta--item meta--date">
   61:                  <?php echo get_the_date(); ?>
   62               </div>
   63  

9 matches across 7 files

What do I do about it? Please do help. Will be much appreciated. Thank you.



via Chebli Mohamed

Make code snippet into a foreach loop

I have a piece of code which is used to replace double dashes for commas in a wordpress taxonomy called “authors” before displaying values to the end user.

This is working great, but now I need to apply it to several different taxonomies, no just “authors” but also “printers”, “translators”, etc.

My idea was to build an array of taxonomies instead of a single variable and then use a foreach loop to apply the find and replace to each of them, but no matter how I try it I can’t seem to make it work…

Any idea how to make the following code into a foreach loop if $custom_taxonomy_type was an array?

This is the code that is currently working for a single taxonomy.

if(!is_admin()){ // make sure the filters are only called in the frontend

$custom_taxonomy_type = 'authors';  // here goes your taxonomy type

function comma_taxonomy_filter($tag_arr){
    global $custom_taxonomy_type;
    $tag_arr_new = $tag_arr;
    if($tag_arr->taxonomy == $custom_taxonomy_type && strpos($tag_arr->name, '--')){
        $tag_arr_new->name = str_replace('--',', ',$tag_arr->name);
    }
    return $tag_arr_new;    
}
add_filter('get_authors', comma_taxonomy_filter);

function comma_taxonomies_filter($tags_arr){
    $tags_arr_new = array();
    foreach($tags_arr as $tag_arr){
        $tags_arr_new[] = comma_taxonomy_filter($tag_arr);
    }
    return $tags_arr_new;
}
add_filter('get_the_taxonomies',    comma_taxonomies_filter);
add_filter('get_terms',             comma_taxonomies_filter);
add_filter('get_the_terms',         comma_taxonomies_filter);

}

As requested by @Epodax here are the two things I've tried so far. Both result in a blank page:

if(!is_admin()){ // make sure the filters are only called in the frontend

    $custom_taxonomy_type_array = array('authors', 'printer');  // here goes your taxonomy type

    foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
        function comma_taxonomy_filter($tag_arr){
            global $custom_taxonomy_type;
            $tag_arr_new = $tag_arr;
            if($tag_arr->taxonomy == $custom_taxonomy_type && strpos($tag_arr->name, '--')){
                $tag_arr_new->name = str_replace('--',', ',$tag_arr->name);
            }
            return $tag_arr_new;    
        }
        add_filter('get_'.$custom_taxonomy_type, comma_taxonomy_filter);

        function comma_taxonomies_filter($tags_arr){
            $tags_arr_new = array();
            foreach($tags_arr as $tag_arr){
                $tags_arr_new[] = comma_taxonomy_filter($tag_arr);
            }
            return $tags_arr_new;
        }
        add_filter('get_the_taxonomies',    comma_taxonomies_filter);
        add_filter('get_terms',             comma_taxonomies_filter);
        add_filter('get_the_terms',         comma_taxonomies_filter);
    }


}

and

if(!is_admin()){ // make sure the filters are only called in the frontend

    $custom_taxonomy_type_array = array('authors', 'printer');  // here goes your taxonomy type

    function comma_taxonomy_filter($tag_arr){
        foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
            global $custom_taxonomy_type;
            $tag_arr_new = $tag_arr;
            if($tag_arr->taxonomy == $custom_taxonomy_type && strpos($tag_arr->name, '--')){
                $tag_arr_new->name = str_replace('--',', ',$tag_arr->name);
            }
            return $tag_arr_new;    
        }
    }
    foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
        add_filter('get_'.$custom_taxonomy_type, comma_taxonomy_filter);
    }

    function comma_taxonomies_filter($tags_arr){
        foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
            $tags_arr_new = array();
            foreach($tags_arr as $tag_arr){
                $tags_arr_new[] = comma_taxonomy_filter($tag_arr);
            }
            return $tags_arr_new;
        }
    }
    foreach ($custom_taxonomy_type_array as $custom_taxonomy_type) {
        add_filter('get_the_taxonomies',    comma_taxonomies_filter);
        add_filter('get_terms',             comma_taxonomies_filter);
        add_filter('get_the_terms',         comma_taxonomies_filter);
    }

}



via Chebli Mohamed