In that case, I will create script files dynamically.
my-layer.php:
require_once QA_PLUGIN_DIR.'my-plugin/my-class.php'; class qa_html_theme_layer extends qa_html_theme_base { public function head_script() { $this->content['script'][] = '<script src="'.MyClass::get_js_path().'?'.QA_VERSION.'"></script>'; qa_html_theme_base::head_script(); } }
my-class.php:
class MyClass { public static function get_js_path() { $relativepath = 'qa-plugin/my-plugin/js/myplugin.js'; self::create_js($relativepath); return qa_path($relativepath, null, null, QA_URL_FORMAT_NEAT); } public static function create_js($relativepath, $force=false) { $absolutepath = QA_BASE_DIR.$relativepath; if($force || !file_exists($absolutepath)) { $js = ''; $js .= 'var lang = "'.qa_lang('main/1_answer').'";'."\n"; file_put_contents($absolutepath, $js); } } }
Welcome to the Q&A site for Question2Answer.
If you have a question about Q2A, please ask here, in English.
To report a bug, please create a new issue on Github or ask a question here with the bug tag.
If you just want to try Q2A, please use the demo site.