From 616c20337b957f0f728eb6651b55a8995a593f8e Mon Sep 17 00:00:00 2001 From: Paul Gueltekin Date: Sat, 22 Oct 2016 19:41:45 +0200 Subject: [PATCH 1/4] removed the usage of already existing treenodes with the same title because the displayed parent path would not be correct --- decision-trees.php | 53 ++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/decision-trees.php b/decision-trees.php index 37eed86..754253e 100644 --- a/decision-trees.php +++ b/decision-trees.php @@ -169,20 +169,19 @@ function process_add_answer() { $answer_meta = array(); $title = trim( $answer['page_title'] ); - $page = get_page_by_title( $title, OBJECT, $this->post_type ); - - if ( !$page ) { - $this->no_recursion = true; - $page_id = wp_insert_post( array( - 'post_title' => $title, - 'post_type' => $this->post_type, - 'post_status' => 'draft', - 'post_parent' => $post->ID, - ) ); - wp_update_post( array( 'ID' => $page_id, 'post_name' => sanitize_title_with_dashes( $answer['text'] ) ) ); - $page = get_post( $page_id ); - $this->no_recursion = false; - } + + + $this->no_recursion = true; + $page_id = wp_insert_post( array( + 'post_title' => $title, + 'post_type' => $this->post_type, + 'post_status' => 'draft', + 'post_parent' => $post->ID, + ) ); + wp_update_post( array( 'ID' => $page_id, 'post_name' => sanitize_title_with_dashes( $answer['text'] ) ) ); + $page = get_post( $page_id ); + $this->no_recursion = false; + $answer_meta['_cftp_dt_answer_value'] = $answer['text']; $answer_meta['_cftp_dt_answer_type'] = $answer_type; @@ -406,20 +405,18 @@ function action_save_post( $post_id, $post ) { $answer_meta = array(); $title = trim( $answer['page_title'] ); - $page = get_page_by_title( $title, OBJECT, $this->post_type ); - - if ( !$page ) { - $this->no_recursion = true; - $page_id = wp_insert_post( array( - 'post_title' => $title, - 'post_type' => $this->post_type, - 'post_status' => 'draft', - 'post_parent' => $post->ID, - ) ); - wp_update_post( array( 'ID' => $page_id, 'post_name' => sanitize_title_with_dashes( $answer['text'] ) ) ); - $page = get_post( $page_id ); - $this->no_recursion = false; - } + + $this->no_recursion = true; + $page_id = wp_insert_post( array( + 'post_title' => $title, + 'post_type' => $this->post_type, + 'post_status' => 'draft', + 'post_parent' => $post->ID, + ) ); + wp_update_post( array( 'ID' => $page_id, 'post_name' => sanitize_title_with_dashes( $answer['text'] ) ) ); + $page = get_post( $page_id ); + $this->no_recursion = false; + $answer_meta['_cftp_dt_answer_value'] = $answer['text']; $answer_meta['_cftp_dt_answer_type'] = $answer_type; From 78ea2e7797c47304cdfb660f319b583b97e37d07 Mon Sep 17 00:00:00 2001 From: Paul Gueltekin Date: Sat, 22 Oct 2016 21:06:15 +0200 Subject: [PATCH 2/4] allow custom fields for tree nodes --- decision-trees.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decision-trees.php b/decision-trees.php index 754253e..7547330 100644 --- a/decision-trees.php +++ b/decision-trees.php @@ -249,7 +249,7 @@ function action_init() { ), 'query_var' => 'help', // @TODO: is this the best qv name? 'delete_with_user' => false, - 'supports' => array( 'title', 'editor', 'page-attributes' ), + 'supports' => array( 'title', 'editor', 'page-attributes', 'custom-fields' ), ); $args = apply_filters( 'cftp_dt_cpt_args', $args ); $cpt = register_post_type( $this->post_type, $args ); From b962c8594eee968f8aeb32691573e38ea75b7b79 Mon Sep 17 00:00:00 2001 From: Paul Gueltekin Date: Sat, 22 Oct 2016 23:47:18 +0200 Subject: [PATCH 3/4] use translation functions for texts --- templates/content-with-history.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/content-with-history.php b/templates/content-with-history.php index 04fe3e3..2990dee 100644 --- a/templates/content-with-history.php +++ b/templates/content-with-history.php @@ -2,7 +2,7 @@
- restart +
@@ -20,7 +20,7 @@
  • post_title; ?>

    get_answer_value(); ?>

    - change this answer +
  • From 273980079a01e8ef83685b6fe18268b10dd2b8f6 Mon Sep 17 00:00:00 2001 From: Paul Gueltekin Date: Sun, 23 Oct 2016 02:43:32 +0200 Subject: [PATCH 4/4] added translation loading and german translation --- cftp_dt-de_DE.mo | Bin 0 -> 2994 bytes cftp_dt-de_DE.po | 153 +++++++++++++++++++++++++++++++++++++++++++++ decision-trees.php | 6 ++ plugin-slug.pot | 142 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 301 insertions(+) create mode 100644 cftp_dt-de_DE.mo create mode 100644 cftp_dt-de_DE.po create mode 100644 plugin-slug.pot diff --git a/cftp_dt-de_DE.mo b/cftp_dt-de_DE.mo new file mode 100644 index 0000000000000000000000000000000000000000..22086c89a14636c9127d9a4304b207098e7bc93c GIT binary patch literal 2994 zcmZ`*&u<$=6ds^JF_a(WH&o~~q7|swO&k!d90ioLE~%QdR^zq^sM@u6;vKS{-OkJ= zZ6q$JCpc6f^$$Smg$uXddO^9s17-}^D&=I_0` zZU{X4s?P)90et>?3}1Ni$Ax$ncp10{_%-lV;CI01fIkBF0)MX7e*wOT@gKmKfOmmU z1OKbm?*m`Pc=r=RJP+Il@FeZ zfd`)~&&zK@P}&t7LfV;3j7{1-T^Y74kp>}D)0dCdNsaP;qSm#Fn?*4=O{cP04rj|jnvO18QEsLvj%6GUMyb*(4^B&S@8 z1HCsZM%@fYZ6l@kyv2g&tZ2r{jd~Z`>7L3+gSMsRtk5wjO>Gm|Bow0yp=d=$>W9v2 zh?dD#6>pEITUeL%DbK7UcQpt7jJiffPEtI`kYi%(W^p<&Un*jH(Ub2A#VE;4Q`q&7GVy|Y8gO@?T(7ft0)_NIi! zW4=~)GX%&y!!n>eK_yWJELLteJtA0ea>!~Q%*RQFy^zLEI7+Z$)fGx*&xT{-oZ8ml z=aem?RN-W9aVt1J4J+`7;yzN;iOjBHd$Nt_CXwcT=Jb|S1ZvNLasz!OyDm5p2j`^W zYt-261>eV14?nD(k$GlZuxNWK4(5uU4cb|Q66bQ;n3z~YH|5+-VP<+0w#eCdqAdQz zAc=u*zFO;aJ2=X130J`}B%nc4ll6~+`eZQm0ZmRd>W2?aPEAhM7EdfTH#ybA$=cCO zJ7gQ>258Wcj&h(7oRQook63J5{amQlY!wa7JWH7S4GuN={c5uIf`O%9S)LnduNh zfy_!B4vc(DZJBPSP8yA19!{uOLUgGkK3mh#Qfyl+w%m@i4q0kKv0#HD&?;`@XskXa zJ z*59~oEqIUUuUBP$>x|5@D$}Yo9iOP`uz^fNr{|-!uwOBNbkB%)aV;{ttn0 zi%V*=g|+-|g7@CEkZ#9sfy5$M5FFdFo=^zM1+BUhD&)l+Y1sM3&=>SMT5HxT`+`)+ bH`E^4+7y8cV&fWm8mZ;9R#f?VlnVbp)9ixJ literal 0 HcmV?d00001 diff --git a/cftp_dt-de_DE.po b/cftp_dt-de_DE.po new file mode 100644 index 0000000..bfd416e --- /dev/null +++ b/cftp_dt-de_DE.po @@ -0,0 +1,153 @@ +# Copyright (C) 2016 Decision Trees +# This file is distributed under the same license as the Decision Trees package. +msgid "" +msgstr "" +"Project-Id-Version: Decision Trees 1.4\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/decision-trees\n" +"POT-Creation-Date: 2016-10-23 02:17+0200\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"PO-Revision-Date: 2016-10-23 02:27+0200\n" +"Language-Team: \n" +"X-Generator: Poedit 1.8.11\n" +"Last-Translator: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: de\n" + +#: class-answers-simple.php:68 class-answers-simple.php:83 +msgid "Answer link text" +msgstr "Antwortlink Text" + +#: class-plugin.php:135 +msgid "" +"This plugin template could not be found, perhaps you need to hook " +"`sil_plugins_dir` and `sil_plugins_url`: %s" +msgstr "" +"Dieses Plugin Template konnte nicht gefunden werden, vielleicht müssen " +"`sil_plugins_dir` und `sil_plugins_url` verbunden werden: %s" + +#: decision-trees.php:122 +msgid "Answer added." +msgstr "Antwort hinzugefügt" + +#: decision-trees.php:222 decision-trees.php:225 decision-trees.php:237 +msgid "Decision Node" +msgstr "Entscheidungsknoten" + +#: decision-trees.php:223 +msgctxt "add new on admin bar" +msgid "Decision Node" +msgstr "Entscheidungsknoten [ Zur Admin Leiste neu hinzufügen]" + +#. Plugin Name of the plugin/theme +#: decision-trees.php:224 decision-trees.php:236 +msgid "Decision Trees" +msgstr "Entscheidungsbäume" + +#: decision-trees.php:226 +msgid "Add New Node" +msgstr "Neuen Knoten hinzufügen" + +#: decision-trees.php:227 +msgid "Add New Decision Node" +msgstr "Neuen Entscheidungsknoten hinzufügen" + +#: decision-trees.php:228 +msgid "Edit Decision Node" +msgstr "Entscheidungsknoten bearbeiten" + +#: decision-trees.php:229 +msgid "New Decision Node" +msgstr "Neuen Entscheidungsknoten" + +#: decision-trees.php:230 +msgid "View Decision Node" +msgstr "Entscheidungsknoten ansehen" + +#: decision-trees.php:231 +msgid "Search Decision Nodes" +msgstr "Entscheidungsknoten suchen" + +#: decision-trees.php:232 +msgid "No nodes found." +msgstr "Keine Konten gefunden." + +#: decision-trees.php:233 +msgid "No nodes found in Trash." +msgstr "Keine Knoten im Papierkorb gefunden." + +#: decision-trees.php:234 +msgid "Parent Decision Node:" +msgstr "Elternentscheidungsknoten" + +#: decision-trees.php:235 +msgid "All Decision Nodes" +msgstr "Alle Entscheidungsknoten" + +#: decision-trees.php:264 decision-trees.php:265 +msgid "Visualise Nodes" +msgstr "Knoten visualisieren" + +#: decision-trees.php:530 +msgid "Answers" +msgstr "Antworten" + +#: templates/content-with-history.php:5 +msgid "restart" +msgstr "Neustart" + +#: templates/content-with-history.php:23 +msgid "change this answer" +msgstr "Ändern der Antwort" + +#: templates-admin/meta-box-answers.php:7 +msgid "" +"Tip: as this is the first decision node in your tree, use it to orient your " +"visitor and then add a single answer with link text similar to \"start\". " +"The decision tree proper will then start on the second node." +msgstr "" +"Tipp: Benutze den ersten Entscheidungsknoten im Baum um den Besuchern bei " +"der Orientierung zu helfen und füge eine einzelne Antwort mit einem Link " +"Text wie \"Start\" hinzu. Der Entscheidungsbaum startet dann mit dem " +"zweiten Knoten." + +#: templates-admin/meta-box-answers.php:12 +msgid "" +"Tip: phrase the answer link text as a statement, e.g. \"It has six legs.\"" +msgstr "" +"Tipp: Schreibe den Antworttext als eine Aussage wie \"Es hat sechs Beine\"" + +#: templates-admin/meta-box-answers.php:17 +msgid "Add An Answer" +msgstr "Eine Antwort hinzufügen" + +#: templates-admin/meta-box-answers.php:26 templates-admin/visualise.php:59 +msgid "Answer page title" +msgstr "Antwort Seitentitel" + +#: templates-admin/visualise.php:4 +msgid "Decision Tree Nodes" +msgstr "Entscheidungsbaumknoten" + +#: templates-admin/visualise.php:65 +msgid "Add »" +msgstr "Hinzufügen »" + +#. Plugin URI of the plugin/theme +msgid "https://github.com/cftp/decision-trees" +msgstr "" + +#. Description of the plugin/theme +msgid "Provides a custom post type to create decision trees in WordPress" +msgstr "" +"Stellt einen Custom Post Type zur Erstellung von Entscheidungsbäumen in " +"Wordpress zur Verfügung" + +#. Author of the plugin/theme +msgid "Code for the People" +msgstr "" + +#. Author URI of the plugin/theme +msgid "http://codeforthepeople.com/" +msgstr "" diff --git a/decision-trees.php b/decision-trees.php index 7547330..107fcd5 100644 --- a/decision-trees.php +++ b/decision-trees.php @@ -105,6 +105,7 @@ public function __construct() { add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) ); add_action( 'admin_menu', array( $this, 'action_admin_menu' ) ); add_action( 'admin_notices', array( $this, 'action_admin_notices' ) ); + add_action( 'plugins_loaded', array( $this, 'dt_init' ) ); # Filters add_filter( 'the_content', array( $this, 'filter_the_content' ) ); @@ -631,6 +632,11 @@ function get_answer_providers() { } + function dt_init() { + $plugin_dir = basename(dirname(__FILE__)); + load_plugin_textdomain( 'cftp_dt', false, $plugin_dir ); + } + } // Initiate the singleton diff --git a/plugin-slug.pot b/plugin-slug.pot new file mode 100644 index 0000000..f7c714b --- /dev/null +++ b/plugin-slug.pot @@ -0,0 +1,142 @@ +# Copyright (C) 2016 Decision Trees +# This file is distributed under the same license as the Decision Trees package. +msgid "" +msgstr "" +"Project-Id-Version: Decision Trees 1.4\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/decision-trees\n" +"POT-Creation-Date: 2016-10-23 00:06:08+00:00\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" + +#: class-answers-simple.php:68 class-answers-simple.php:83 +msgid "Answer link text" +msgstr "" + +#: class-plugin.php:135 +msgid "" +"This plugin template could not be found, perhaps you need to hook " +"`sil_plugins_dir` and `sil_plugins_url`: %s" +msgstr "" + +#: decision-trees.php:122 +msgid "Answer added." +msgstr "" + +#: decision-trees.php:222 decision-trees.php:225 decision-trees.php:237 +msgid "Decision Node" +msgstr "" + +#: decision-trees.php:223 +msgctxt "add new on admin bar" +msgid "Decision Node" +msgstr "" + +#. #-#-#-#-# plugin-slug.pot (Decision Trees 1.4) #-#-#-#-# +#. Plugin Name of the plugin/theme +#: decision-trees.php:224 decision-trees.php:236 +msgid "Decision Trees" +msgstr "" + +#: decision-trees.php:226 +msgid "Add New Node" +msgstr "" + +#: decision-trees.php:227 +msgid "Add New Decision Node" +msgstr "" + +#: decision-trees.php:228 +msgid "Edit Decision Node" +msgstr "" + +#: decision-trees.php:229 +msgid "New Decision Node" +msgstr "" + +#: decision-trees.php:230 +msgid "View Decision Node" +msgstr "" + +#: decision-trees.php:231 +msgid "Search Decision Nodes" +msgstr "" + +#: decision-trees.php:232 +msgid "No nodes found." +msgstr "" + +#: decision-trees.php:233 +msgid "No nodes found in Trash." +msgstr "" + +#: decision-trees.php:234 +msgid "Parent Decision Node:" +msgstr "" + +#: decision-trees.php:235 +msgid "All Decision Nodes" +msgstr "" + +#: decision-trees.php:264 decision-trees.php:265 +msgid "Visualise Nodes" +msgstr "" + +#: decision-trees.php:530 +msgid "Answers" +msgstr "" + +#: templates/content-with-history.php:5 +msgid "restart" +msgstr "" + +#: templates/content-with-history.php:23 +msgid "change this answer" +msgstr "" + +#: templates-admin/meta-box-answers.php:7 +msgid "" +"Tip: as this is the first decision node in your tree, use it to orient your " +"visitor and then add a single answer with link text similar to \"start\". " +"The decision tree proper will then start on the second node." +msgstr "" + +#: templates-admin/meta-box-answers.php:12 +msgid "" +"Tip: phrase the answer link text as a statement, e.g. \"It has six legs.\"" +msgstr "" + +#: templates-admin/meta-box-answers.php:17 +msgid "Add An Answer" +msgstr "" + +#: templates-admin/meta-box-answers.php:26 templates-admin/visualise.php:59 +msgid "Answer page title" +msgstr "" + +#: templates-admin/visualise.php:4 +msgid "Decision Tree Nodes" +msgstr "" + +#: templates-admin/visualise.php:65 +msgid "Add »" +msgstr "" + +#. Plugin URI of the plugin/theme +msgid "https://github.com/cftp/decision-trees" +msgstr "" + +#. Description of the plugin/theme +msgid "Provides a custom post type to create decision trees in WordPress" +msgstr "" + +#. Author of the plugin/theme +msgid "Code for the People" +msgstr "" + +#. Author URI of the plugin/theme +msgid "http://codeforthepeople.com/" +msgstr ""