Devam Ediyor

525110 js/php code modification - quick & easy NEED ASAP

I need a small part of a Wordpress plugin modified with js and php.

The plugin is a content warning script that pulls up a thickbox and displays a page for the visitor to agree that they are 18 years or older before they enter the site.

Right now it pops up on all pages. I need to modify it so it will only pop up on certain pages/posts/categories.

I have modified the theme options page to include an input box where the admin will enter a list of pagess, post and category id's separated by commas.

There are basically two lines of code that activate the message on all pages, one in a php function and the other a js function. The first one gets the Wordpress url and sends it to the js function where it calls up thickbox and the warning message.

First line of code (php):

echo 'var wpcw_wpurl = "'.get_bloginfo('wpurl').'";'."\n";

This lines grabs the Wordpress url and assigns it to wpcw_wpurl.

The next line of code (js):

tb_show('Warning', wpcw_wpurl + '/?wpcw=message&height=300&width=700&modal=true',false);

This line calls thickbox by appending thickbox settings after the Wordpress url.

Instead of applying the content warning to all pages under the site root, I need the script to parse out the Wordpress ID from the url, check it against the ID listed in the theme options page and if the current ID is a match, display call the thickbox warning message.

Parsing a Wordpress post/page ID from the url is easy:

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<?php

global $post;

echo $post->ID;

?>

<?php endwhile; ?>

<?php endif; ?>

This returns a number like 619.

To parse a Wordpress category:

<?php

foreach((get_the_category()) as $category) {

echo $category->cat_ID;

} ?>

This also returns a nice number like 53.

In the theme options page I added a text input filed to capture the ID. The user will add the ID or ID's and separate them by commas.

You need to write a little code to strip out the commas, toss the ID's into an array, use the two pieces of code I provided to parse out a post/page id or a category ID and if the ID matches the array call up thickbox and the message.

The Wordpress script I am using is Content Warning [url removed, login to view]

You can see how it works by going to [url removed, login to view]

I am working on other parts of the Content Warning script so it will look and act differently if you visit it more than once.

There are only two files you need work with:

[url removed, login to view] and wpcp.js.

It may sound involved but it's not and should take less than one hour. Its mostly about looking over the code real quick, write an array and strip out the commas, parse the Wprdpress url ID out and check the ID against the array and if the url ID matches, activate the exiting thickbox call.

MAX Budget is: $40.

p.s.

[url removed, login to view] = line 37

[url removed, login to view] = line 11

[url removed, login to view] = line 56-72 (this is the theme options page and where the ID input box is located.

NOTE: the theme options page has a radio button that checks to see if the admin wants the warning message turned off, enabled for all pages or just certain page/post and categories.

The Off feature works, the entire site works you just need to check to see if the certain pages/post and categories button is active and then do as I laid out above.

Beceriler: Her şey Kabul, Javascript, PHP, Web Sitesi Yönetimi, WordPress

Daha fazlasını görün: parsing input, look php, laid work, js do, works global, need quick code wordpress, write plugin wordpress, write code php, use quick text, activate plugins wordpress, global p, first code, code that, code radio, code line, category php, p sound, max p, if js, echo parts, text parsing, php radio, need write code, modal, code check

İşveren Hakkında:
( 1 değerlendirme ) United States

Proje NO: #2271049