Plugin Directory

Changeset 2723063


Ignore:
Timestamp:
05/13/2022 12:39:13 AM (4 years ago)
Author:
shorthandconnect
Message:

Bumping versions

Location:
shorthand-connect
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • shorthand-connect/tags/1.3.12/README.txt

    r2687312 r2723063  
    33Donate link:
    44Tags: shorthand, api
    5 Requires at least: 4
    6 Tested up to: 5.9.1
    7 Stable tag: 1.3.10
     5Requires at least: 4.0
     6Tested up to: 5.9.3
     7Stable tag: 1.3.12
     8Requires PHP: 5.6
    89License: GPLv2 or later
    910License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    28294. Optionally change the CSS settings in the options to best present stories within your theme.
    29305. Optionally your theme can override the display of Shorthand stories via `single-shorthand_story.php` in your theme directory.
     316. Optionally apply post-processing in the form of regex queries; within Settings, Post-Processing.
     32
     33~~~
     34 {
     35  "head":
     36  [
     37    {
     38      "query":  "/<title.(.*?)<\/title>/",
     39      "replace":""
     40    },
     41    {
     42      "query":  "/regex string/",
     43      "replace":"String to replace it"
     44    },
     45    ...
     46   
     47  ],
     48  "body":[]
     49}
     50~~~
     51
    3052
    3153== Updating ==
     
    3759
    3860== Changelog ==
     61
     62= 1.3.12 =
     63* Bumping versions
     64
     65= 1.3.11 =
     66* Added Post-processing Regex JSON for stripping/modifying head and body content of Shorthand Stories. Also added custom field "no_update"; if true, updating the Wordpress Shorthand Story won't fetch and replace the existing content.
    3967
    4068= 1.3.10 =
  • shorthand-connect/tags/1.3.12/includes/shorthand_options.php

    r2687312 r2723063  
    4646        update_option('sh_api_version', sanitize_text_field($_POST['sh_api_version']));
    4747    }
     48
    4849    $token = esc_html(get_option('sh_token_key'));
    4950    $v2_token = esc_html(get_option('sh_v2_token'));
    5051    $user_id = esc_html(get_option('sh_user_id'));
    5152    $sh_api_version = esc_html(get_option('sh_api_version'));
     53   
    5254
    5355    if( isset($_POST['sh_submit_hidden_two']) && $_POST['sh_submit_hidden_two'] == 'Y' && check_admin_referer( 'sh-update-configuration' ) ) {
     
    7577        $sh_css = $default_sh_site_css;
    7678    }
     79
     80    if(isset($_POST['sh_submit_hidden_four']) && $_POST['sh_submit_hidden_four'] == 'Y' && check_admin_referer( 'sh-update-configuration' ) ) {
     81        update_option('sh_regex_list', base64_encode(wp_unslash($_POST['sh_regex_list'])));
     82    }
     83
     84    $sh_regex_list = base64_decode(get_option('sh_regex_list'));
    7785
    7886    $profile = sh_get_profile();
     
    150158        </form>
    151159
     160    <h3>Post-processing</h3>
     161        <p>Use this to create a JSON object of regex queries and replacements.</p>
     162        <p><em>This Example removes title tags from within the head tag by replacing it with nothing.</em></p>
     163<pre><code>
     164  {
     165    "head":
     166    [
     167      {
     168        &quot;query&quot;:&quot;/&lt;title.(.*?)&lt;\/title&gt;/&quot;,
     169        &quot;replace&quot;:&quot;&quot;
     170      }
     171    ],
     172    "body":[]
     173  }
     174
     175</code></pre>
     176        <form name="form2" method="post" onsubmit="padJson()">
     177            <?php echo $n_once ?>
     178            <input type="hidden" name="sh_submit_hidden_four" value="Y" />
     179            <textarea rows="10" cols="80" id="sh_regex_list" name="sh_regex_list"><?php echo stripslashes($sh_regex_list); ?></textarea>
     180            <p class="submit">
     181                <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
     182            </p>
     183        </form>
     184        <script>
     185            let textarea = document.querySelector("textarea#sh_regex_list");
     186 
     187            function padJson() {
     188                console.log('updated JSON');
     189                textarea.value = textarea.value.replace(/\\/g, '\\\\');
     190            }
     191           
     192           
     193            textarea.addEventListener("keyup", function(event) {
     194                try{
     195                    JSON.parse(textarea.value);
     196                    textarea.setCustomValidity("");
     197                   
     198                }catch(err){
     199                    if(textarea.value != ""){
     200                        console.log("Invalid JSON");
     201                        textarea.setCustomValidity("Invalid JSON in the Post-processing field");
     202                    }else{
     203                        textarea.setCustomValidity("");
     204                    }
     205                }
     206               
     207            });
     208        </script>
     209
    152210    <style>
    153211        img.grav {
     
    171229            display:none;
    172230        }
     231
     232        code {
     233  font-family: monospace;
     234  display: inherit;
     235}
    173236    </style>
    174237    <script>
  • shorthand-connect/tags/1.3.12/shorthand_connect.php

    r2602733 r2723063  
    33/**
    44 * @package Shorthand Connect
    5  * @version 1.3.9
     5 * @version 1.3.11
    66 */
    77/*
     
    1010Description: Import your Shorthand stories into your Wordpress CMS as simply as possible - magic!
    1111Author: Shorthand
    12 Version: 1.3.9
     12Version: 1.3.11
    1313Author URI: http://shorthand.com
    1414*/
     
    5959        )
    6060    );
    61 
     61   
    6262    register_taxonomy_for_object_type('category', 'shorthand_story');
    6363    register_taxonomy_for_object_type('post_tag', 'shorthand_story');
     
    269269    }
    270270
     271    if(!get_post_meta($post_id, 'no_update')) {
     272        update_post_meta($post_id, 'no_update', "false");
     273    }
     274
    271275    if (isset($_REQUEST['extra_html'])) {
    272276        update_post_meta($post_id, 'extra_html', wp_kses_post($_REQUEST['extra_html']));
    273277    }
    274278
    275     if (isset($_REQUEST['story_id'])) {
     279    if (isset($_REQUEST['story_id']) && get_post_meta($post_id, 'no_update')[0] !== "true") {
     280       
    276281        $safe_story_id = preg_replace("/\W|_/", '', $_REQUEST['story_id']);
    277282        update_post_meta($post_id, 'story_id', sanitize_text_field($safe_story_id));
     
    285290        }
    286291
    287         if (isset($story_path)) {
     292        if (isset($story_path) ) {
    288293            // The story has been uploaded
    289294            update_post_meta($post_id, 'story_path', $story_path);
     
    304309                $article_file = $story_path . '/article.html';
    305310            }
     311            $post_processing_queries = json_decode(base64_decode(get_option('sh_regex_list')));
     312
    306313            $body = shand_fix_content_paths($assets_path, file_get_contents($article_file), $version);
     314            if(isset($post_processing_queries->body)){
     315                $body = shand_post_processing($body,$post_processing_queries->body);
     316            }
    307317            update_post_meta($post_id, 'story_body', wp_slash($body));
    308318            $head = shand_fix_content_paths($assets_path, file_get_contents($head_file), $version);
     319            if(isset($post_processing_queries->head)){
     320                $head = shand_post_processing($head, $post_processing_queries->head);
     321            }
    309322            update_post_meta($post_id, 'story_head', wp_slash($head));
    310323
     
    454467        $content = str_replace('./media/', $assets_path . '/media/', $content);
    455468    }
     469
     470    return $content;
     471}
     472
     473function shand_post_processing($content, $queries)
     474{
     475    if ($queries == null){
     476        return $content;
     477    }
     478   
     479    foreach ($queries as $query) {
     480        if(isset($query->query) && isset($query->replace)){
     481            $content = preg_replace($query->query, $query->replace, $content);
     482        }
     483    }
     484
    456485    return $content;
    457486}
  • shorthand-connect/trunk/README.txt

    r2687312 r2723063  
    33Donate link:
    44Tags: shorthand, api
    5 Requires at least: 4
    6 Tested up to: 5.9.1
    7 Stable tag: 1.3.10
     5Requires at least: 4.0
     6Tested up to: 5.9.3
     7Stable tag: 1.3.12
     8Requires PHP: 5.6
    89License: GPLv2 or later
    910License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    28294. Optionally change the CSS settings in the options to best present stories within your theme.
    29305. Optionally your theme can override the display of Shorthand stories via `single-shorthand_story.php` in your theme directory.
     316. Optionally apply post-processing in the form of regex queries; within Settings, Post-Processing.
     32
     33~~~
     34 {
     35  "head":
     36  [
     37    {
     38      "query":  "/<title.(.*?)<\/title>/",
     39      "replace":""
     40    },
     41    {
     42      "query":  "/regex string/",
     43      "replace":"String to replace it"
     44    },
     45    ...
     46   
     47  ],
     48  "body":[]
     49}
     50~~~
     51
    3052
    3153== Updating ==
     
    3759
    3860== Changelog ==
     61
     62= 1.3.12 =
     63* Bumping versions
     64
     65= 1.3.11 =
     66* Added Post-processing Regex JSON for stripping/modifying head and body content of Shorthand Stories. Also added custom field "no_update"; if true, updating the Wordpress Shorthand Story won't fetch and replace the existing content.
    3967
    4068= 1.3.10 =
  • shorthand-connect/trunk/includes/shorthand_options.php

    r2687312 r2723063  
    4646        update_option('sh_api_version', sanitize_text_field($_POST['sh_api_version']));
    4747    }
     48
    4849    $token = esc_html(get_option('sh_token_key'));
    4950    $v2_token = esc_html(get_option('sh_v2_token'));
    5051    $user_id = esc_html(get_option('sh_user_id'));
    5152    $sh_api_version = esc_html(get_option('sh_api_version'));
     53   
    5254
    5355    if( isset($_POST['sh_submit_hidden_two']) && $_POST['sh_submit_hidden_two'] == 'Y' && check_admin_referer( 'sh-update-configuration' ) ) {
     
    7577        $sh_css = $default_sh_site_css;
    7678    }
     79
     80    if(isset($_POST['sh_submit_hidden_four']) && $_POST['sh_submit_hidden_four'] == 'Y' && check_admin_referer( 'sh-update-configuration' ) ) {
     81        update_option('sh_regex_list', base64_encode(wp_unslash($_POST['sh_regex_list'])));
     82    }
     83
     84    $sh_regex_list = base64_decode(get_option('sh_regex_list'));
    7785
    7886    $profile = sh_get_profile();
     
    150158        </form>
    151159
     160    <h3>Post-processing</h3>
     161        <p>Use this to create a JSON object of regex queries and replacements.</p>
     162        <p><em>This Example removes title tags from within the head tag by replacing it with nothing.</em></p>
     163<pre><code>
     164  {
     165    "head":
     166    [
     167      {
     168        &quot;query&quot;:&quot;/&lt;title.(.*?)&lt;\/title&gt;/&quot;,
     169        &quot;replace&quot;:&quot;&quot;
     170      }
     171    ],
     172    "body":[]
     173  }
     174
     175</code></pre>
     176        <form name="form2" method="post" onsubmit="padJson()">
     177            <?php echo $n_once ?>
     178            <input type="hidden" name="sh_submit_hidden_four" value="Y" />
     179            <textarea rows="10" cols="80" id="sh_regex_list" name="sh_regex_list"><?php echo stripslashes($sh_regex_list); ?></textarea>
     180            <p class="submit">
     181                <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
     182            </p>
     183        </form>
     184        <script>
     185            let textarea = document.querySelector("textarea#sh_regex_list");
     186 
     187            function padJson() {
     188                console.log('updated JSON');
     189                textarea.value = textarea.value.replace(/\\/g, '\\\\');
     190            }
     191           
     192           
     193            textarea.addEventListener("keyup", function(event) {
     194                try{
     195                    JSON.parse(textarea.value);
     196                    textarea.setCustomValidity("");
     197                   
     198                }catch(err){
     199                    if(textarea.value != ""){
     200                        console.log("Invalid JSON");
     201                        textarea.setCustomValidity("Invalid JSON in the Post-processing field");
     202                    }else{
     203                        textarea.setCustomValidity("");
     204                    }
     205                }
     206               
     207            });
     208        </script>
     209
    152210    <style>
    153211        img.grav {
     
    171229            display:none;
    172230        }
     231
     232        code {
     233  font-family: monospace;
     234  display: inherit;
     235}
    173236    </style>
    174237    <script>
  • shorthand-connect/trunk/shorthand_connect.php

    r2602733 r2723063  
    33/**
    44 * @package Shorthand Connect
    5  * @version 1.3.9
     5 * @version 1.3.11
    66 */
    77/*
     
    1010Description: Import your Shorthand stories into your Wordpress CMS as simply as possible - magic!
    1111Author: Shorthand
    12 Version: 1.3.9
     12Version: 1.3.11
    1313Author URI: http://shorthand.com
    1414*/
     
    5959        )
    6060    );
    61 
     61   
    6262    register_taxonomy_for_object_type('category', 'shorthand_story');
    6363    register_taxonomy_for_object_type('post_tag', 'shorthand_story');
     
    269269    }
    270270
     271    if(!get_post_meta($post_id, 'no_update')) {
     272        update_post_meta($post_id, 'no_update', "false");
     273    }
     274
    271275    if (isset($_REQUEST['extra_html'])) {
    272276        update_post_meta($post_id, 'extra_html', wp_kses_post($_REQUEST['extra_html']));
    273277    }
    274278
    275     if (isset($_REQUEST['story_id'])) {
     279    if (isset($_REQUEST['story_id']) && get_post_meta($post_id, 'no_update')[0] !== "true") {
     280       
    276281        $safe_story_id = preg_replace("/\W|_/", '', $_REQUEST['story_id']);
    277282        update_post_meta($post_id, 'story_id', sanitize_text_field($safe_story_id));
     
    285290        }
    286291
    287         if (isset($story_path)) {
     292        if (isset($story_path) ) {
    288293            // The story has been uploaded
    289294            update_post_meta($post_id, 'story_path', $story_path);
     
    304309                $article_file = $story_path . '/article.html';
    305310            }
     311            $post_processing_queries = json_decode(base64_decode(get_option('sh_regex_list')));
     312
    306313            $body = shand_fix_content_paths($assets_path, file_get_contents($article_file), $version);
     314            if(isset($post_processing_queries->body)){
     315                $body = shand_post_processing($body,$post_processing_queries->body);
     316            }
    307317            update_post_meta($post_id, 'story_body', wp_slash($body));
    308318            $head = shand_fix_content_paths($assets_path, file_get_contents($head_file), $version);
     319            if(isset($post_processing_queries->head)){
     320                $head = shand_post_processing($head, $post_processing_queries->head);
     321            }
    309322            update_post_meta($post_id, 'story_head', wp_slash($head));
    310323
     
    454467        $content = str_replace('./media/', $assets_path . '/media/', $content);
    455468    }
     469
     470    return $content;
     471}
     472
     473function shand_post_processing($content, $queries)
     474{
     475    if ($queries == null){
     476        return $content;
     477    }
     478   
     479    foreach ($queries as $query) {
     480        if(isset($query->query) && isset($query->replace)){
     481            $content = preg_replace($query->query, $query->replace, $content);
     482        }
     483    }
     484
    456485    return $content;
    457486}
Note: See TracChangeset for help on using the changeset viewer.