HTML and Script not show in my wordpress theme - php

I'm using a custom theme option framework on my theme. I have been integrated everything, but in textarea when paste and try to save option it automatic remove HTML codes and <script> only text and <> are remain. Text showing in my website source page here http://www.wrock.org/ I don't know how to resolve this problem.
Also there is some google tracking code, and when I explored the source I found the following
/* ----------------------------------------------------------------------------------- */
/* Show analytics code in footer */
/* ----------------------------------------------------------------------------------- */
function wrockmetro_analytics() {
$shortname = wrockmetro_get_option('of_shortname');
$output = wrockmetro_get_option($shortname . 'wrock_analytics');
if ($output <> "")
echo "<script type='text/javascript'>" . stripslashes($output) . "</script>\n";
}
add_action('wp_footer', 'wrockmetro_analytics');
Textarea code from OptionInterface.php
// Textarea
case 'textarea':
$cols = '8';
$ta_value = '';
if (isset($value['options'])) {
$ta_options = $value['options'];
if (isset($ta_options['cols'])) {
$cols = $ta_options['cols'];
} else {
$cols = '8';
}
}
$val = stripslashes($val);
$output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>';
break;

Related

Last posts text limit characters in phpbb

I found this code for showing last posts in phpbb forum. I wanna set charatcters limit in post_text.
<?php
// Now let's output the content
// A ted vypsat obsah
while ($row = $db->sql_fetchrow($result))
{
$url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}"; //added fedforum to url
$urlmini = generate_board_url() . "/memberlist.{$phpEx}?mode=viewprofile&u={$row['poster_id']}"; //added fedforum to url
//old line $url = generate_board_url() . "viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}";
echo '<small><a target="_blank" href="' . $url . '">' . $row['post_subject']. '</a><br>'. $row['post_text'] .'<br>od: <a target="_blank" href="' . $urlmini . '">' . ucwords($row['username']).'</a>' . ' v '.'<font style="color:#aaa;">' . date("H:i",$row['post_time']).'</font>', '<br><br></small>';
}
?>
Does anybody know how to set characters limit for $row['post_text'] ?
you can use
substr($row['post_text'],0,40);
or change 40 to any limit as you want

Trouble with Wordpress Pretty Photo Pin It Button

If you go to http://jbrazeal.com/galleries/bridals you can see my website with a PrettyPhoto gallery within a Wordpress theme. By default, when you click on a picture, the picture expands and gives you an option to "Tweet" or to "Like" the photos with buttons below the picture. I have installed a plugin called "prettyPhoto Media Pinterest" (https://github.com/Lawdawg/prettyphoto-media-pinterest) where it adds a "Pin It" button to each specific picture.
However, the plugin is only working for some pages and not others. It works on the page linked above, but it does not work on the other gallery pages. For instance, it does not work for any of the pictures on the page /galleries/weddings (I couldn't post the link because I am limited to two links.
Below is the PHP. I assume it is a PHP problem, but if you advise me otherwise, I can post up any other relevant information (the plugin has a javascript file as well). Additionally, you can see actual webpage as well as the plugin page as I linked above. Thanks!
<?php
add_action('init', 'ppm_pinterest_init');
function ppm_pinterest_init() {
define('PPM_PINTEREST_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
define('PPM_PINTEREST_VERSION', '0.1' );
if (!is_admin()) {
wp_enqueue_style('ppm_pinterest', PPM_PINTEREST_URI . 'css/ppm-pinterest.css', false, PPM_PINTEREST_VERSION, 'screen');
wp_enqueue_script('pinterest_plus', PPM_PINTEREST_URI . 'js/pinterest-plus.min.js', false, false, true);
add_action('wp_footer', 'ppm_pinterest_footer_script', 101);
}
}
function ppm_pinterest_footer_script() {
$out = '<script>' . "\n";
$out .= 'jQuery(function($) {' . "\n";
$out .= ' $(document).bind(\'DOMNodeInserted\', function(event) {' . "\n";
$out .= ' if (window.settings && !window.settings.changepicturecallbackupdated) {' . "\n";
$out .= ' window.settings.changepicturecallback = add_pinterest_pin_it_button' . "\n";
$out .= ' window.settings.changepicturecallbackupdated = true;' . "\n";
$out .= ' }' . "\n";
$out .= ' });' . "\n";
$out .= '});' . "\n";
$out .= "\n";
$out .= 'function add_pinterest_pin_it_button() {' . "\n";
$out .= ' var i = jQuery(\'.pp_gallery\').find(\'li\').index(jQuery(\'.selected\'));' . "\n";
$out .= ' var m = pp_images[i];' . "\n";
$out .= ' jQuery(\'.pp_social\').append(\'<div class="pinterest"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></div>\');' . "\n";
$out .= '}' . "\n";
$out .= '</script>' . "\n";
echo $out;
}
?>
I figured it out. You can view my plugin branch here, which works now!
https://github.com/Lawdawg/prettyphoto-media-pinterest
I changed the jQuery call to:
$out .= ' jQuery(\'.pp_social\').append(\'<div class="pinterest"><a target="_blank" href="http://pinterest.com/pin/create/button/?url=\' + encodeURI(location.href.replace(location.hash,"")) + \'&media=\' + encodeURI(m) + \'&description=\' + encodeURI(o) + \'" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a></div>\');' . "\n";
$out .= '}' . "\n";

google checkout php callback explained

Hi all i don't know if i'm doing this right or not but i can't understand how google checkout works.
I have the php code that sends the XML to the google checkout everything is ok i reach on the checkout process taxes prices shipping is ok.
$_currency = $params['currency'];
$base_domain = 'https://' . (($params['mode'] == 'transaction') ? 'checkout.google.com' : 'sandbox.google.com/checkout');
$base_url = $base_domain . '/cws/v2/Merchant/' . $params['merchantId'] . '/checkout';
// Form XML array with cart items
$_items = '';
$google_products = $this->CI->go_cart->contents();
foreach ($google_products as $k => $v) {
$item_options = '';
if (isset($v['options'])) {
foreach ($v['options'] as $name => $value) {
if (is_array($value)) {
foreach ($value as $item) {
$item_options .= $item;
}
} else {
$item_options .= $value;
}
}
}
$_items .= '<item>' . '<merchant-item-id>' . $v['id'] . '</merchant-item-id>' . '<item-name>' . strip_tags($v['name']) . ' ' . $item_options . '</item-name>' . '<item-description>' . substr(strip_tags($item_options), 0, 299) . '</item-description>' . "<unit-price currency='" . $_currency . "'>" . $v['price'] . '</unit-price>' . '<quantity>' . $v['quantity'] . '</quantity>' . '</item>';
}
$xml_cart = "<?xml version='1.0' encoding='UTF-8'?>
<checkout-shopping-cart xmlns='http://checkout.google.com/schema/2'>
<shopping-cart>
<merchant-private-data>
<additional_data>
<session_id>" . base64_encode($customer['bill_address']["email"] . date('h:i:s')) . "</session_id>
<currency_code>" . $_currency . "</currency_code>
<payment_id>" . base64_encode($customer['bill_address']["email"] . date('h:i:s')) . "</payment_id>
" . $private_ship_data . "
</additional_data>
</merchant-private-data>
<items>" . $_items . "</items>
</shopping-cart>
<checkout-flow-support>
<merchant-checkout-flow-support>
<platform-id>971865505315434</platform-id>
<request-buyer-phone-number>true</request-buyer-phone-number>
<edit-cart-url>" . $edit_cart_url . "</edit-cart-url>
<merchant-calculations>
<merchant-calculations-url>" . $calculation_url . "</merchant-calculations-url>
</merchant-calculations>
<continue-shopping-url>" . $return_url . "</continue-shopping-url>
" . $shippings . $taxes . "
</merchant-checkout-flow-support>
</checkout-flow-support>
</checkout-shopping-cart>";
$signature = $this->fn_calc_hmac_sha1($xml_cart, $params['merchantKey']);
$b64_cart = base64_encode($xml_cart);
$b64_signature = base64_encode($signature);
echo '<form method="post" action="' . $base_url . '" name="BB_BuyButtonForm">
<input type="hidden" name="cart" value="' . $b64_cart . '" />
<input type="hidden" name="signature" value="' . $b64_signature . '" />
<input alt="" src="' . $base_domain . '/buttons/checkout.gif?merchant_id=' . $params['merchantId'] . '&w=160&h=43&style=' . 'white' . '&variant=text&loc=en_US" type="image"/>
</form>';
exit;
}
After i click on submit payment i'm then redirected to a page with successfull message and with a link to return to my website.
I'm wondering how can i check if the payment was or not successfully.
Also there is a callback that i don't know exactly what is supposed to do.
Please help me understand better
I have attached the code below.
Disclaimer: Am not a PHP dev.
Your code above is known as Part 1. Checkout API documented here. It covers how you get your data/cart to Google for Checkout
Part II. Order Processing covers how to get data from Google (into your systems). A tutorial is provided here. This is where you provide a Callback API URL that listens to (waits for) HTTP POSTs from Google and proceed to process the data.

Query not display rows only on IE

In my php class I created a method for concatenated select form (ajax call)
Now I've a strange problem because in firefox, chrome and other browsers the method
go well displaying the rows of my query select while in ie 8-9 no display rows but only a "white" window.
public function ShowCat_2( $idca2, $idca1 ) {
// for edit function
$where = "";
if(isset($idca1)){ $where .= " idcat_1='$idca1'"; }
if(isset($_POST['idcat_1'])) { $where .= " idcat_1='$_POST[idcat_1]'"; }
// query
$this->db->result = $this->db->mysqli->query("SELECT * FROM cat_2 WHERE $where");
$cat_2 = '<option value="0">Select</option>';
while($row = $this->db->result->fetch_assoc()) {
$cat_2 .= '<option value="' . $row['idcat_2'] . '"';
if($idca2 == $row['idcat_2']){ $cat_2 .= ' selected'; } // for edit fun
$cat_2 .= '>' . utf8_encode(ucfirst(strtolower($row['descr']))) . '</option>';
}
return $cat_2;
}
Can you tell me what could be the problem and how to solve?
Thanks
Take a look at the page source. There may be a PHP warning / notice in there that's breaking the HTML code.

How can I add custom image sizes to wordpress but have them in the admin?

I know how to use add_image_size in PHP to register a new size which can be used in templates.
It makes images in this size, too when they're uploaded.
The sizes I added like that don't show in the admin, though.
So 2 questions...
How can I get the image sizes that I make show up in the 'upload image' thing when bloggers make a new post?
Is there a way to list it in the admin so the bloggers can add new ones without having to change PHP code?
Or am I doing something wrong, like not putting the add_image_size call in the right place/file? Are sizes like this supposed to show up in the upload menu section?
Cole
Wordpress doesn't show custom image size options in the media lightbox, but you can add them using an attachment_fields_to_edit filter. The below will add options for all the custom image sizes you have defined.
add_filter('attachment_fields_to_edit', 'my_attachment_fields_to_edit_filter', 100, 2);
function my_attachment_fields_to_edit_filter($form_fields, $post) {
if (!array_key_exists('image-size', $form_fields)) return $form_fields;
global $_wp_additional_image_sizes;
foreach($_wp_additional_image_sizes as $size => $properties) {
if ($size == 'post-thumbnail') continue;
$label = ucwords(str_replace('-', ' ', $size));
$cssID = "image-size-{$size}-{$post->ID}";
$downsize = image_downsize($post->ID, $size);
$enabled = $downsize[3];
$html = '<input type="radio" ' . disabled($enabled, false, false) . 'name="attachments[' . $post->ID. '][image-size]" id="' . $cssID . '" value="' . $size .'">';
$html .= '<label for="'. $cssID . '">' . $label . '</label>';
if ($enabled) $html .= ' <label for="' . $cssID . '" class="help">(' . $downsize[1] . ' × ' . $downsize[2] . ')</label>';
$form_fields['image-size']['html'] .= '<div class="image-size-item">' . $html . '</div>';
}
return $form_fields;
}

Categories