0

I recently incorporated a new interface into my wordpress site that mimics an iGoogle layout. (If interested, It can be found here: Link and DEMO )

It uses several widgets to make up the layout that are added dynamically. The way to edit these widgets come from a file called widgets_rpc.php. I want to add another plugin I have, which allows users to edit text that is wrapped in a shortcode - [ce_sc did="1"][/ce_sc]. When some text is wrapped in this shortcode is clicked, it allows users to edit the text, and also shows "save' "Toggle editor" buttons below the text. When done with the changes, the user clicks "save" to save.

I read about how to include shortcodes in PHP pages outside the wordpress theme, and ended up with this for the widgets_rpc.php file:

<?php
require('../../mysite/wp-blog-header.php');
?>
<?php

header("Cache-Control: no-cache");
header("Pragma: nocache");

$id=$_REQUEST["id"];



if ($id=="widget1")
  echo do_shortcode("[ce_sc did='1']<p></p>[/ce_sc]");

if ($id=="widget2")
  echo do_shortcode('[ce_sc did="2"]<p></p>[/ce_sc]');

if ($id=="widget3")
  echo do_shortcode ("[ce_sc did='4']<p></p>[/ce_sc]");

So this actually works, almost. It acts as the shortcode regularly does, by allowing user to add text and even pops up a "save" "toggle editor" button on the bottom of the text area, but does not do anything when I click these buttons (as it normally does when done through wordpress). Is there a different method I could try for better results? Or am I missing a crucial step in the shortcode's function in php outside the theme?

Thanks!

PS. This site is on my local computer using server2go as development, otherwise I would have included a link.

2
  • I am pretty sure that there is significant relevant code missing, though it sounds like the shortcode works but, probably, the Javascript doesn't. – s_ha_dum Mar 1 '14 at 16:39
  • Good point! If I am including the blog header, shouldn't it call the same js that the plugin calls in a page/post? Or do I need to include some kind of call for the js in this outside php file too? – Taberkinslaw Mar 1 '14 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.