Plugin Directory

Changeset 1215794


Ignore:
Timestamp:
08/08/2015 01:19:46 PM (11 years ago)
Author:
aaronbelchamber
Message:

Tested with WP 4.3, added $json_string array that gets passed to your script the $json_vals_arr array from your JSON string.

Location:
insert-script/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • insert-script/trunk/insert-script.php

    r1197008 r1215794  
    33/**
    44 * @package Insert_Script
    5  * @version 1.1
     5 * @version 1.3
    66 */
    77/*
    88Plugin Name: Insert Script
    99Plugin URI: http://belchamber.us/wordpress/plugins/insert-script.zip
    10 Description: With the [insert_script] shortcode, this calls on the absolute path of any script from the path you provide with the "path=" attribute.
     10Description: With the [insert_script] shortcode, this calls on the absolute path of any script from the path you provide with the "path=" attribute.  Now allows "vals" and "strings" as GET URL attribute,
     11             "json_string" for properly encoded JSON string arrays will return $json_vals_arr to your script, and passes on "save_db" and "section" as $save_db and $section variables to whatever values you assign them to your external scripts.
    1112Author: Aaron Belchamber
    12 Version: 1.1
     13Version: 1.3
    1314Author URI: http://www.belchamber.us
    1415*/
     
    4344
    4445        function shortcode($atts){
    45             extract(shortcode_atts(array("path" => '',"vars"=>''), $atts));
     46            /*
     47             * Dynamically include file from path
     48             *
     49             * $path  String
     50             * example [insert_script path='/resources/main.php'] (paths start at public_html)
     51             *
     52             * $strings   Uses PHP parse_str function -- look it up
     53             *
     54             */
     55
    4656            ob_start();
    47             include($_SERVER['DOCUMENT_ROOT'].$path);
    48             return ob_get_clean();
     57
     58            extract(shortcode_atts(array('path' => '','vals'=>'','strings' => '','save_db' => '','section'=>'','json_string'=>''), $atts));
     59            $path=html_entity_decode(trim($path));
     60            $strings=html_entity_decode(trim($strings));
     61            $vals=html_entity_decode(trim($vals));
     62            $save_db=html_entity_decode(trim($save_db));
     63            $section=html_entity_decode(trim($section));
     64
     65            $json_string=html_entity_decode(trim($json_string));
     66            $json_vals_arr=json_decode($json_string,true);
     67
     68            if ($strings!=''){
     69                parse_str($strings);// Assign strings before including file to parse to inject values
     70            }
     71
     72            if ($vals!=''){
     73                parse_str($vals);
     74            }
     75
     76            if ($path!=''){
     77                @include($_SERVER['DOCUMENT_ROOT'].$path);
     78            }
     79
     80            $html=ob_get_clean();
     81            return $html;
    4982        }
    5083
  • insert-script/trunk/readme.txt

    r1197011 r1215794  
    44Tags: insert,shortcode,insert script,php
    55Requires at least: 3.0.1
    6 Tested up to: 4.2.2
     6Tested up to: 4.3
    77Stable tag: /trunk/
    88License: GPLv2 or later
     
    1414With the [insert_script] shortcode, this calls on the absolute path of any script from the path you provide with the "path=" attribute.
    1515It can also pass along declared variables from a "vars=" attribute where you can define GET values in URL safe declarations -- whatever
    16 the script you are calling on requires.  This allows a level of back-end integration with code, processes, and data outside of Wordpress.
     16the script you are calling on requires. 
     17
     18Now allows "vals" and "strings" you define with GET URL attribute (var1=value1&var2=value2).
     19Also pass JSON Array via "json_string" for properly encoded JSON string arrays which will pass array $json_vals_arr to your script, and passes on "save_db" and "section" as $save_db and $section variables to whatever values you assign them to your external scripts.
     20This allows a level of back-end integration with code, processes, and data outside of Wordpress.
    1721
    1822
     
    2933== Changelog ==
    3034
    31 No changes made in  past two years and still works with every version of Wordpress to date.
     351.3 Added new variables and ability to declare scalable "json_string" which will pass $json_vals_arr JSON array to your script too.
     36
     371.1 No changes made in  past two years and still works with every version of Wordpress to date.
Note: See TracChangeset for help on using the changeset viewer.