コード例 #1
0
ファイル: MetaBox.php プロジェクト: artovenry/wp
 function render($post, $args)
 {
     extract($this->options);
     $class = $this->post_type_class;
     $post_type = $this->post_type;
     $locals = array_merge(["post_type" => $post_type, $post_type => $class::build($post)], $args);
     Haml::render_box($template, $locals, $this->nonce_key(), $this->nonce_name());
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: EscoreBu/metrics-bot
 protected function check_for_haml($path)
 {
     $haml_path = $path . ".haml";
     if (!file_exists($haml_path)) {
         return $path;
     }
     $new_path = RA_CACHE_PATH . "/haml" . substr($path, strlen(RA_VIEWS_PATH));
     if (file_exists($new_path)) {
         $current = filemtime($haml_path);
         $old = filemtime($new_path);
         if ($current <= $old) {
             return $new_path;
         }
     }
     require_once RA_VENDOR_PATH . "/haml/lib/haml.php";
     $haml = new Haml();
     $generated = $haml->parse(file_get_contents($haml_path));
     Ra_DirectoryHelper::mkdir($new_path, true);
     file_put_contents($new_path, $generated);
     return $new_path;
 }
コード例 #3
0
ファイル: Initializer.php プロジェクト: artovenry/wp
 private function register_post_type($class, $meta_boxes)
 {
     if (empty($options = $class::options_for("post_type_options"))) {
         return false;
     }
     if (isset($class::$post_type_options) and is_string($class::$post_type_options)) {
         $options = ["name" => static::$post_type_options];
     }
     if (empty($options["label"])) {
         $options["label"] = $options["name"];
     }
     $options = array_merge(Base::DEFAULT_POST_TYPE_OPTIONS, $options);
     $options["register_meta_box_cb"] = function () use($meta_boxes) {
         Haml::initialize(MetaBox::VIEWPATH);
         foreach ($meta_boxes as $item) {
             $item->register();
         }
     };
     add_action("init", function () use($options) {
         register_post_type($options["name"], $options);
     });
 }