• I’m working on allowing users to edit a section of my plugin output in the admin area ( so it loads the default template code and they can customize it ). Initially I stored the customized template in the db, but this makes it impossible to make some text section multilingual.

    There are some plugin functions that they can call in the template code like this {{my_plugin_function( $args )}} which is replaced with the output from the function when the output is shown on the front-end, but I can’t think of a way to make that work with texts for different languages when the template customizations are stored in the db.

    Only thing I can think of is to create a new folder in the wp-uploads folder and store the template code there as .tmpl / .html or so, and esc_html__( ‘my_text’, ‘my_domain’ ) can be used. But this kind of feels wrong to me, isn’t the /wp-uploads folder only for image / file uploads? Or would it be acceptable for me to create a new folder there to store custom template sections?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can store what files you like in /wp-content/{custom-folder}/ or /uploads/, but storing textual data in individual files is sub-optimal. You’re better off saving such data in the DB. Using custom tables like iconithemes suggests is one approach, although you can organize a similar data organization within the existing WP schema. For example, the main templates can be saved custom post types and translations can be saved as child posts under each main template “parent”. The advantage of using the WP schema is there are numerous built-in functions we can use to save and access data. If you create custom tables, you’d need to create your own functions to do the same things that WP already does for you. It’s totally feasible to do so, but it increases the development work needed to get to a solution.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.