{"id":73068,"date":"2017-08-15T13:26:33","date_gmt":"2017-08-15T13:26:33","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/template-dictionary\/"},"modified":"2020-11-16T19:42:58","modified_gmt":"2020-11-16T19:42:58","slug":"template-dictionary","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/template-dictionary\/","author":15601934,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.6.1","stable_tag":"1.6.1","tested":"5.5.18","requires":"4.5","requires_php":"","requires_plugins":"","header_name":"Template Dictionary","header_author":"Radovan Knebl\u00edk","header_description":"A plugin for developers which provides template variables dictionary editable in backend.","assets_banners_color":"","last_updated":"2020-11-16 19:42:58","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":10,"downloads":1807,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","changelog"],"tags":{"1.0":{"tag":"1.0","author":"radovank","date":"2017-08-15 13:28:51"},"1.01":{"tag":"1.01","author":"radovank","date":"2017-08-15 17:14:56"},"1.02":{"tag":"1.02","author":"radovank","date":"2017-09-13 23:04:32"},"1.3":{"tag":"1.3","author":"radovank","date":"2017-10-30 22:31:12"},"1.4":{"tag":"1.4","author":"radovank","date":"2017-11-01 18:59:19"},"1.5":{"tag":"1.5","author":"radovank","date":"2019-07-01 17:49:16"},"1.6":{"tag":"1.6","author":"radovank","date":"2019-08-02 08:37:58"},"1.6.1":{"tag":"1.6.1","author":"radovank","date":"2020-11-16 19:42:58"}},"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.01","1.02","1.3","1.4","1.5","1.6","1.6.1"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":1713711,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":1713711,"resolution":"2","location":"assets","locale":""},"screenshot-3.png":{"filename":"screenshot-3.png","revision":1713711,"resolution":"3","location":"assets","locale":""},"screenshot-4.png":{"filename":"screenshot-4.png","revision":1713711,"resolution":"4","location":"assets","locale":""},"screenshot-5.png":{"filename":"screenshot-5.png","revision":1713711,"resolution":"5","location":"assets","locale":""},"screenshot-6.png":{"filename":"screenshot-6.png","revision":1713711,"resolution":"6","location":"assets","locale":""}},"screenshots":{"1":"Setting up a variable","2":"Filling out values","3":"Values list","4":"Various field types","5":"Export\/Import page","6":"Using values in template"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[8880,2218,1253,975,2276],"plugin_category":[43,47],"plugin_contributors":[145047],"plugin_business_model":[],"class_list":["post-73068","plugin","type-plugin","status-publish","hentry","plugin_tags-dictionary","plugin_tags-options","plugin_tags-settings","plugin_tags-template","plugin_tags-variables","plugin_category-customization","plugin_category-education-and-support","plugin_contributors-radovank","plugin_committers-radovank"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/template-dictionary.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/template-dictionary\/assets\/screenshot-1.png?rev=1713711","caption":"Setting up a variable"},{"src":"https:\/\/ps.w.org\/template-dictionary\/assets\/screenshot-2.png?rev=1713711","caption":"Filling out values"},{"src":"https:\/\/ps.w.org\/template-dictionary\/assets\/screenshot-3.png?rev=1713711","caption":"Values list"},{"src":"https:\/\/ps.w.org\/template-dictionary\/assets\/screenshot-4.png?rev=1713711","caption":"Various field types"},{"src":"https:\/\/ps.w.org\/template-dictionary\/assets\/screenshot-5.png?rev=1713711","caption":"Export\/Import page"},{"src":"https:\/\/ps.w.org\/template-dictionary\/assets\/screenshot-6.png?rev=1713711","caption":"Using values in template"}],"raw_content":"<!--section=description-->\n<p>Template Dictionary is a plugin which can be used to create template variables editable by admins.<\/p>\n\n<p>The plugin is multilingual ready. It includes Polylang integration, another multilingual plugin can be integrated with filters.<\/p>\n\n<h4>Admin pages<\/h4>\n\n<p>There are few admin pages for managing the plugin.<\/p>\n\n<ul>\n<li><strong>Template Dictionary<\/strong> \u2013 view, edit and delete the template variables values<\/li>\n<li><strong>Settings list<\/strong> \u2013 view, edit and delete template variables settings<\/li>\n<li><strong>Add setting<\/strong> \u2013 add new or edit template variables setting<\/li>\n<li><strong>Edit values<\/strong> \u2013 edit a value, this page is accessable from the page <strong>Template Dictionary<\/strong><\/li>\n<li><strong>Export\/Import<\/strong> \u2013 export settings and values to xml or import it from xml<\/li>\n<\/ul>\n\n<h4>Usage in template<\/h4>\n\n<p>You can use a value in template by calling function <code>get<\/code> of Template Dictionary object, which can be accessed by function <code>TmplDict()<\/code>.<\/p>\n\n<p>For example, if you set a setting with code <em>the_code<\/em>, you can use it's value by:<\/p>\n\n<pre><code>TmplDict()-&gt;get( 'the_code' );\n<\/code><\/pre>\n\n<p>This function returns the value. If you need to echo the value, you can use function <code>eget<\/code>. Both functions have an optional argument <code>$default<\/code>, which is the default returned\/echoed value, if the admin value is empty.<\/p>\n\n<p>You can also get the value by accessing the code as property:<\/p>\n\n<pre><code>$value = TmplDict()-&gt;the_code;\n<\/code><\/pre>\n\n<h4>Usage with shortcode<\/h4>\n\n<p>You can also use a shortcode <code>[tmpl_dict]<\/code> with attributes <code>code<\/code>, <code>default<\/code> and <code>do_shortcode<\/code>. The last attribute says, if the function <code>do_shortcode<\/code> will be called on the value.<\/p>\n\n<h4>Setup template language<\/h4>\n\n<p>Default template language can be set by setting the constant <code>TMPL_DICT_DEFAULT_LANG<\/code> in wp-config. Default value of this constant consists of two first characters of the current WP locale. <strong>It is important to set the default language constant properly if you plan to create your site multilingual in future.<\/strong><\/p>\n\n<p><strong>If you have a multilingual site<\/strong>, you need to set current template language with the filter <code>template_dictionary_language<\/code>. For users of Polylang, it is already integrated in this plugin, the current template language is the Polylang current language slug.<\/p>\n\n<h4>Setup available languages<\/h4>\n\n<p><strong>If you have a multilingual site<\/strong>, you also need to set available languages with the filter <code>template_dictionary_languages<\/code>. Again, if Polylang is activated, these available languages consist of Polylang languages slugs.<\/p>\n\n<p>If your site is not multilingual, there is only one available language \u2013 the default language.<\/p>\n\n<h4>Use JS object<\/h4>\n\n<p>To generate JavaScript dictionary object, you need to define <code>TMPL_DICT_JS_VAR_NAME<\/code> constant. Add to <code>wp_config.php<\/code>:<\/p>\n\n<pre><code>define( 'TMPL_DICT_JS_VAR_NAME', 'dict' );\n<\/code><\/pre>\n\n<p>Then you can use it in JS:<\/p>\n\n<pre><code>$('#some-element').text( dict.the_code );\n<\/code><\/pre>\n\n<!--section=changelog-->\n<h4>1.6.1<\/h4>\n\n<ul>\n<li>Fix: When exporting both settings and values, export empty settings too.<\/li>\n<li>Fix: Correct number of placeholders for wpdb::prepare.<\/li>\n<\/ul>\n\n<h4>1.6<\/h4>\n\n<ul>\n<li>Added method to get whole dictionary array.<\/li>\n<li>Added JS dictionary object.<\/li>\n<\/ul>\n\n<h4>1.5<\/h4>\n\n<ul>\n<li>Added term field type.<\/li>\n<li>Add admin info notice if <code>TMPL_DICT_DEFAULT_LANG<\/code> constant is not set.<\/li>\n<\/ul>\n\n<h4>1.4<\/h4>\n\n<ul>\n<li>Fix: Page for editing settings was not showing.<\/li>\n<li>Show admin submenu opened on Edit Values page.<\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<ul>\n<li>Fix: screen option per_page on settings list<\/li>\n<li>Enabled caching of values<\/li>\n<li>Set user locale as language in admin if it is in available languages list.<\/li>\n<li>Refactored admin pages<\/li>\n<\/ul>\n\n<h4>1.02<\/h4>\n\n<ul>\n<li>Added post-multiple field type.<\/li>\n<li>Added method __get for accessing dictionary values as properties.<\/li>\n<\/ul>\n\n<h4>1.01<\/h4>\n\n<ul>\n<li>Fix: notice after deleting setting<\/li>\n<li>Do not show empty field options in settings list.<\/li>\n<\/ul>","raw_excerpt":"A plugin for developers which provides template variables dictionary editable in backend.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/73068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=73068"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/radovank"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=73068"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=73068"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=73068"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=73068"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=73068"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=73068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}