/** * Get box property. * * @param array $properties * * @return array */ function papi_get_box_property(array $properties) { $box_property = array_filter($properties, function ($property) { return !is_object($property); }); if (!empty($box_property) && !isset($box_property[0]) && !isset($box_property[0]['tab'])) { $property = papi_property($properties); if (!$property->disabled()) { $property->_box_property = true; $properties = [$property]; } } return $properties; }
<?php return ['title' => 'Sidebar', papi_property(['slug' => 'sidebar_post', 'title' => __('Sidebar Reference', 'intra'), 'description' => __('Points to another page sidebar', 'intra'), 'type' => 'post', 'settings' => ['placeholder' => 'No page selected, inherit startpage if sidebar empty', 'post_type' => 'page']]), papi_property(['slug' => 'sidebar', 'title' => __('Sidebar', 'intra'), 'description' => __('If no sidebar reference then place modules here!', 'intra'), 'type' => 'relationship', 'rules' => [['operator' => '=', 'value' => null, 'slug' => 'sidebar_post']], 'settings' => ['post_type' => 'module']])];
/** * Render layout JSON template. * * @param string $slug */ protected function render_json_template($slug) { $options = $this->get_options(); foreach ($options->settings->items as $key => $value) { if (!isset($value['items'])) { continue; } foreach ($value['items'] as $index => $property) { $property = $this->prepare_property_for_json(papi_property($property)); if ($property === false) { unset($options->settings->items[$key]['items'][$index]); continue; } $options->settings->items[$key]['items'][$index] = $property; } } papi_render_html_tag('script', ['data-papi-json' => esc_attr(sprintf('%s_repeater_json', $slug)), 'type' => 'application/json', papi_maybe_json_encode([$options])]); }
public function register() { $this->remove(['editor']); $this->box('Content', [papi_property(['type' => 'Image', 'title' => 'Hero image']), papi_property(['title' => 'Feature', 'slug' => 'feature_module', 'type' => 'post', 'settings' => ['text' => 'Select module', 'post_type' => ['module', 'post']]])]); }
/** * Get properties via POST. * * POST /papi-ajax/?action=get_properties */ public function get_properties() { if (!papi_get_sanitized_post('properties')) { $this->render_error('No properties found'); return; } $items = json_decode(stripslashes($_POST['properties']), true); if (empty($items) || !is_array($items)) { $this->render_error('No properties found'); return; } foreach ($items as $key => $item) { $property = papi_property((array) $item); if (!papi_is_property($property)) { unset($items[$key]); continue; } ob_start(); $property->render_ajax_request(); $items[$key] = trim(ob_get_clean()); } $items = array_filter($items); if (empty($items)) { $this->render_error('No properties found'); } else { wp_send_json(['html' => $items]); } }
<?php return ['title' => __('Allmänna modulinställningar', 'lobbykit'), papi_property(['slug' => 'anonymous_only', 'title' => __('Anonym enbart', 'lobbykit'), 'description' => __('Visas endast för anonym besökare', 'lobbykit'), 'type' => 'bool'])];
/** * Render layout input. * * @param string $slug * @param string $value */ protected function render_layout_input($slug, $value) { // Creating a fake hidden property to generate right slug. $slug = $this->html_name(papi_property(['type' => 'hidden', 'slug' => $slug . $this->layout_key]), $this->counter); ?> <input type="hidden" name="<?php echo $slug; ?> " value="<?php echo $value; ?> " /> <?php }
<?php return ['title' => 'Main', 'description' => 'sasdas', papi_property(['slug' => 'modules', 'title' => __('Modules', 'intra'), 'description' => __('Modules to display on page', 'intra'), 'type' => 'relationship', 'settings' => ['post_type' => 'module']])];
public function register() { $this->box(__('Innehåll', 'aekeb'), [papi_property(['slug' => 'headline', 'title' => __('Rubrik', 'aekab'), 'description' => __('Förstarubrik i text', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'intro', 'title' => __('Introduktionstext', 'aekab'), 'type' => 'text']), papi_property(['slug' => 'headline2', 'title' => __('Andrarubrik, inledning', 'aekab'), 'description' => __('Under intro och före textblocken', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'blocks', 'title' => __('Textblock', 'aekab'), 'description' => __('Flera rader med innehållsblock', 'aekab'), 'type' => 'repeater', 'settings' => ['items' => [papi_property(['slug' => 'headline', 'title' => __('Rubrik', 'aekab'), 'description' => __('Förstarubrik i text', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'text', 'title' => __('Text', 'aekab'), 'type' => 'text'])]]])]); $this->box(__('Kontaktinnehåll', 'aekab'), [papi_property(['slug' => 'contact', 'title' => __('Modul för kontakt', 'aekab'), 'description' => __('Vilken kontakt ska denna text peka på för utvisning?', 'aekab'), 'type' => 'post', 'settings' => ['placeholder' => __('Välj en modul som är kontakt', 'aekab'), 'post_type' => ['module'], 'query' => ['meta_key' => PAPI_PAGE_TYPE_KEY, 'meta_value' => 'modules/contact']]])]); }
public function register() { $this->remove(['editor']); $this->box('Content', [papi_property(['title' => 'Sections', 'type' => 'flexible', 'sidebar' => false, 'settings' => ['items' => [['title' => 'Twitter', 'items' => [papi_property(['title' => 'Twitter name 1', 'type' => 'string']), papi_property(['title' => 'Twitter name 2', 'type' => 'string']), papi_property(['title' => 'Twitter name 3', 'type' => 'string'])]], ['title' => 'Images', 'items' => [['title' => 'Image left', 'type' => 'image'], ['title' => 'Image right', 'type' => 'image']]], ['title' => 'Editor', 'items' => [papi_property(['title' => 'Editor', 'type' => 'editor'])]]]]])]); }
public function register() { $this->box(__('Authentication', 'intra'), [papi_property(['slug' => 'profile_page', 'title' => __('Profile page', 'intra'), 'type' => 'post', 'settings' => ['placeholder' => __('No profile page set!', 'intra'), 'post_type' => 'page']])]); $this->box(__('Mandrill settings', 'intra'), [papi_property(['slug' => 'mandrill_from_name', 'title' => __('From Name', 'intra'), 'type' => 'string']), papi_property(['slug' => 'mandrill_from', 'title' => __('From Email', 'intra'), 'type' => 'string']), papi_property(['slug' => 'mandrill_key', 'title' => __('Secret Key', 'intra'), 'type' => 'string'])]); }
public function register() { $this->box(__('Authentication', 'intra'), [papi_property(['slug' => 'message_login', 'title' => __('Login', 'intra'), 'description' => __('Shows when the user tries to login to LobbyKit', 'intra'), 'type' => 'editor']), papi_property(['slug' => 'message_forgot', 'title' => __('Forgot', 'intra'), 'description' => __('When the user tries to get a login link', 'intra'), 'type' => 'editor']), papi_property(['slug' => 'message_register', 'title' => __('Register', 'intra'), 'description' => __('When the user tries to register new account', 'intra'), 'type' => 'editor']), papi_property(['slug' => 'message_new_account', 'title' => __('New account success', 'intra'), 'description' => __('When a new account is created with the green new message to user', 'intra'), 'type' => 'editor']), papi_property(['slug' => 'message_email_welcome', 'title' => __('Email welcome', 'intra'), 'description' => __('Email text when user gets new welcome mail', 'intra'), 'type' => 'editor'])]); }
public function register() { $this->box(__('test', 'intra'), [papi_property(['slug' => 'test', 'title' => __('TEST', 'intra'), 'type' => 'string'])]); $this->box(__('Bildspel', 'intra'), [papi_property(['slug' => 'carousel', 'title' => __('Bilder', 'intra'), 'type' => 'repeater', 'settings' => ['items' => [papi_property(['slug' => 'image', 'title' => __('Bild', 'intra'), 'type' => 'image']), papi_property(['slug' => 'link', 'title' => __('Destination', 'intra'), 'type' => 'link'])]]])]); $this->box(dirname(__FILE__) . '/parts/module.php'); }
public function register() { $this->box(__('Payoffens inställningar', 'aekab'), [papi_property(['slug' => 'words', 'title' => __('Innehåll', 'aekab'), 'description' => __('Den text som visas ut som payoff', 'aekab'), 'type' => 'text']), papi_property(['slug' => 'type', 'title' => __('Typ av payoff', 'aekab'), 'description' => __('Välj vilken sort som ska visas ut', 'aekab'), 'type' => 'dropdown', 'default' => 1, 'settings' => ['items' => [__('Vit', 'aekab') => 1, __('Grå', 'aekab') => 2]]])]); }
/** * Register content meta box. */ public function register() { $this->box('Medialistningar', [papi_property(['title' => 'Medialistning', 'slug' => 'relation', 'type' => 'relationship', 'settings' => ['post_type' => 'module', 'query' => ['meta_key' => PAPI_PAGE_TYPE_KEY, 'meta_value' => 'modules/medialisting']]]), papi_property(['title' => 'Ordning', 'slug' => 'sort_order', 'type' => 'number', 'description' => 'Lägst går först i listningar', 'default' => '100'])]); }
<?php return ['title' => __('Sidans moduler på sidan', 'aekeb'), papi_property(['slug' => 'page_modules', 'title' => __('Sidans moduler', 'aekab'), 'description' => __('Välj de moduler som sidan ska visa samt vilken ordning', 'orasolv'), 'type' => 'relationship', 'settings' => ['post_type' => 'module']])];
public function register() { $this->box(__('Text', 'lobbykit'), [papi_property(['slug' => 'text', 'title' => __('Innehåll', 'lobbykit'), 'type' => 'editor'])]); $this->box(__('Kortknapp', 'lobbykit'), [papi_property(['slug' => 'link', 'title' => __('Länk', 'lobbykit'), 'type' => 'link'])]); $this->box(dirname(__FILE__) . '/parts/module.php'); }
public function register() { $this->remove(['editor']); $this->box('Content', [papi_property(['title' => 'Pages', 'type' => 'repeater', 'sidebar' => false, 'settings' => ['items' => papi_property(['title' => 'Page', 'type' => 'post', 'settings' => ['text' => '', 'post_type' => 'page', 'query' => ['meta_query' => [['key' => papi_get_page_type_key(), 'compare' => 'NOT EXISTS']]]]])]])]); }
/** * Add new property to the page using array or rendering property template file. * * @param array|string $file_or_options * @param array $values * * @return null|Papi_Property */ protected function property($file_or_options = [], $values = []) { return papi_property($file_or_options, $values); }
<?php return ['title' => __('Designupplägg', 'aekeb'), papi_property(['slug' => 'paper_start', 'title' => __('Papper', 'aekab'), 'description' => __('Startar sidan med pappersunderlägg?', 'orasolv'), 'type' => 'bool'])];
public function register() { $this->remove(['editor', 'comments', 'thumbnail']); $this->box('Module content', [papi_property(['type' => 'string', 'title' => 'Title']), papi_property(['type' => 'image', 'title' => 'Image']), papi_property(['title' => 'References', 'type' => 'reference', 'settings' => ['slug' => 'feature_module', 'page_type' => 'article-page-type']])]); }
/** * Registers meta boxes to papi page type * @return void */ public function register() { $this->box(__('Sidfot', 'AEKAB'), [papi_property(['slug' => 'footer_summary', 'title' => __('Summering', 'aekab'), 'description' => __('Företagssummering i sidfoten', 'aekab'), 'type' => 'text']), papi_property(['slug' => 'footer_link1_text', 'title' => __('Länkgrupp 1', 'aekab'), 'description' => __('Text för länkgrupp 1 i sidfoten', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'footer_link1_links', 'title' => __('Länkar 1', 'aekab'), 'description' => __('Länkar för länkgrupp 1 i sidfoten', 'aekab'), 'type' => 'repeater', 'settings' => ['items' => [papi_property(['slug' => 'link', 'title' => __('Länk', 'aekab'), 'type' => 'link'])]]]), papi_property(['slug' => 'footer_link2_text', 'title' => __('Länkgrupp 2', 'aekab'), 'description' => __('Text för länkgrupp 2 i sidfoten', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'footer_link2_links', 'title' => __('Länkar 2', 'aekab'), 'description' => __('Länkar för länkgrupp 2 i sidfoten', 'aekab'), 'type' => 'repeater', 'settings' => ['items' => [papi_property(['slug' => 'link', 'title' => __('Länk', 'aekab'), 'type' => 'link'])]]]), papi_property(['slug' => 'footer_contact_headline', 'title' => __('Rubrik kontakt', 'aekab'), 'description' => __('Rubrik som ligger allra längst ned i sidfot', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'footer_contact_text1', 'title' => __('Kontakttext 1', 'aekab'), 'description' => __('Text udner kontaktrubrik allra längst ned i sidfot', 'aekab'), 'type' => 'text', 'settings' => ['allow_html' => true]]), papi_property(['slug' => 'footer_contact_text2', 'title' => __('Kontakttext 2', 'aekab'), 'description' => __('Text udner kontaktrubrik allra längst ned i sidfot', 'aekab'), 'type' => 'text', 'settings' => ['allow_html' => true]])]); }
/** * Populate properties array. * * @param array|object $properties * * @return array */ function papi_populate_properties($properties) { if (!is_array($properties) && !is_object($properties) || empty($properties)) { return []; } if (is_object($properties)) { return [$properties]; } // Convert all non property objects to property objects. $properties = array_map(function ($property) { if (is_array($property)) { return papi_property($property); } return $property; }, $properties); if (!isset($properties[0])) { $properties = [papi_property($properties)]; } // If the first property is a core tab, just return // the properties array and skip the last check. if (empty($properties) || $properties[0] instanceof Papi_Core_Tab) { return papi_sort_order($properties); } return papi_sort_order(array_filter(array_reverse($properties), 'papi_is_property')); }
public function register() { $this->remove('editor'); $this->box('test', [papi_property(['title' => 'Url', 'description' => 'This should default to value `http://whatever.com`', 'slug' => 'url', 'type' => 'text', 'default' => 'http://whatever.com']), papi_property(['title' => 'Counter', 'description' => 'This should default to value `0`', 'slug' => 'counter', 'type' => 'number', 'default' => 0, 'value' => 0])]); }
public function register() { $this->box(__('Kontakt', 'aekeb'), [papi_property(['slug' => 'name', 'title' => __('Namn', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'title', 'title' => __('Titel', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'phone_text', 'title' => __('Telefon -text', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'phone_tel', 'title' => __('Telefon -nummerlänk', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'email', 'title' => __('E-postadress', 'aekab'), 'type' => 'string'])]); }
public function register() { $this->box('Top menu', [papi_property(['slug' => 'top_pages', 'title' => 'Top Pages', 'type' => 'repeater', 'settings' => ['items' => [['slug' => 'page', 'type' => 'post', 'settings' => ['post_type' => 'page']]]]])]); $this->box('Categories', [papi_property(['slug' => 'public_categories', 'title' => 'Public Categories', 'type' => 'repeater', 'description' => 'Selected categories will show on pages as public reference links', 'settings' => ['items' => [['slug' => 'term', 'type' => 'term', 'settings' => ['taxonomy' => 'category']]]]])]); $this->box('Footer', [papi_property(['slug' => 'footer_text', 'title' => 'Footer Text', 'type' => 'editor', 'description' => 'Show text in the footer'])]); }
public function register() { $this->box(__('Innehåll', 'aekab'), [papi_property(['slug' => 'herotext', 'title' => __('Uppslagstext', 'aekab'), 'description' => __('Fokuserad uppslagstext under sidans rubrik', 'aekab'), 'type' => 'text'])]); }
public function register() { $this->box(__('Text', 'lobbykit'), [papi_property(['slug' => 'title', 'title' => __('Rubrik', 'lobbykit'), 'type' => 'string']), papi_property(['slug' => 'body', 'title' => __('Beskrivning / intro', 'lobbykit'), 'type' => 'editor'])]); $this->box(dirname(__FILE__) . '/parts/module.php'); }
public function register() { $this->box(__('Innehåll', 'aekab'), [papi_property(['slug' => 'top_word', 'title' => __('Toppord', 'aekab'), 'description' => __('Det som visas allra högst upp med väldigt stora bokstäver', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'headliner', 'title' => __('Rubriklinje', 'aekab'), 'description' => __('Visas under det stora toppordet', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'thirdliner', 'title' => __('Avslutningsrubrik', 'aekab'), 'description' => __('Visas under efter rubriklinjen', 'aekab'), 'type' => 'string']), papi_property(['slug' => 'sellpoint', 'title' => __('Säljtext', 'aekab'), 'description' => __('Säljande text under trippelrubriken', 'aekab'), 'type' => 'text']), papi_property(['slug' => 'link1', 'title' => __('Vidarelänkning 1', 'aekab'), 'description' => __('Knapp #1 för att gå vidare', 'aekab'), 'type' => 'link']), papi_property(['slug' => 'link2', 'title' => __('Vidarelänkning 2', 'aekab'), 'description' => __('Knapp #2 för att gå vidare', 'aekab'), 'type' => 'link'])]); }
public function register() { $this->box(__('Call To Action', 'intra'), [papi_property(['slug' => 'cta', 'title' => __('Link button', 'intra'), 'description' => __('A call to action button / link under text', 'intra'), 'type' => 'link']), papi_property(['slug' => 'cta_color', 'title' => __('Link button color', 'intra'), 'description' => __('The color of the link button', 'intra'), 'type' => 'dropdown', 'settings' => ['placeholder' => __('Select a color!', 'intra'), 'items' => ['No color' => 'btn-secondary', 'Red' => 'btn-danger', 'Green' => 'btn-success', 'Blue' => 'btn-primary', 'Orange' => 'btn-warning', 'Link' => 'btn-link']]])]); $this->box(__DIR__ . '/../Templates/AnonymousOnly.php'); }