Пример #1
0
    /**
     * Renders the markup.
     *
     * @since 3.0.0
     *
     * @return void
     */
    public function render()
    {
        $this->asset_manager->enqueue_style('multilingualpress-admin');
        $action = PluginSettingsUpdater::ACTION;
        ?>
		<div class="wrap">
			<h1><?php 
        echo esc_html(get_admin_page_title());
        ?>
</h1>
			<form method="post" action="<?php 
        echo admin_url("admin-post.php?action={$action}");
        ?>
"
				id="multilingualpress-modules">
				<?php 
        echo \Inpsyde\MultilingualPress\nonce_field($this->nonce);
        ?>
				<table class="mlp-module-list">
					<?php 
        foreach ($this->module_manager->get_modules() as $id => $module) {
            /**
             * Filters if the module should be listed on the settings page.
             *
             * @since 3.0.0
             *
             * @param bool $show_module Whether or not the module should be listed on the settings page.
             */
            if (apply_filters("multilingualpress.show_module_{$id}", true)) {
                $this->render_module($module);
            }
        }
        /**
         * Fires at the end of but still inside the module list on the settings page.
         *
         * @since 3.0.0
         */
        do_action('multilingualpress.in_module_list');
        ?>
				</table>
				<?php 
        /**
         * Fires right after after the module list on the settings page.
         *
         * @since 3.0.0
         */
        do_action('multilingualpress.after_module_list');
        submit_button(__('Save Changes', 'multilingual-press'));
        ?>
			</form>
		</div>
		<?php 
    }
Пример #2
0
 /**
  * Enqueues the front-end styles.
  *
  * @return void
  */
 private function enqueue_style()
 {
     $theme_support = get_theme_support('multilingualpress');
     if (empty($theme_support[0]['language_switcher_widget_style'])) {
         $this->asset_manager->enqueue_style('multilingualpress');
     }
 }
 /**
  * @param string $hook
  *
  * @return void
  */
 public function load_script($hook)
 {
     if ('nav-menus.php' !== $hook) {
         return;
     }
     $this->asset_manager->add_script_data('multilingualpress-admin', 'mlpNavMenusSettings', ['action' => $this->handle, 'metaBoxId' => $this->handle, 'nonce' => (string) $this->nonce, 'nonceName' => $this->nonce->action()]);
 }
 /**
  * Makes the relationship control settings available for JavaScript.
  *
  * @return void
  */
 private function localize_script()
 {
     if (self::$is_script_localized) {
         return;
     }
     $this->asset_manager->add_script_data('multilingualpress-admin', 'mlpRelationshipControlSettings', ['actionConnectExisting' => RelationshipController::ACTION_CONNECT_EXISTING, 'actionConnectNew' => RelationshipController::ACTION_CONNECT_NEW, 'actionDisconnect' => RelationshipController::ACTION_DISCONNECT, 'l10n' => ['noPostSelected' => __('Please select a post.', 'multilingual-press'), 'unsavedRelationships' => __('You have unsaved changes in your post relationships. The changes you made will be lost if you navigate away from this page.', 'multilingual-press')]]);
     /**
      * Filters the minimum number of characters required to fire the live search.
      *
      * @param int $threshold Minimum number of characters required to fire the live search.
      */
     $threshold = (int) apply_filters('multilingualpress.relationship_control_search_threshold', 3);
     $this->asset_manager->add_script_data('multilingualpress-admin', 'mlpLiveSearchSettings', ['action' => SearchController::ACTION, 'argName' => Search::ARG_NAME, 'threshold' => max(1, $threshold)]);
     self::$is_script_localized = true;
 }
Пример #5
0
    /**
     * Returns the remote post links in form of up to three link elements, or a select element for more than three
     * links.
     *
     * @param  string $selections 'option' or 'a' elements.
     * @param  string $type       'links' or 'form'.
     * @param  array  $translated Original array of translated posts, passed to the filter.
     * @param  string $position   Quicklink position.
     *
     * @return string
     */
    protected function get_html_container($selections, $type, $translated, $position)
    {
        $class_inner = 'mlp_inner';
        $label_text = esc_html_x('Read in:', 'Quicklink label', 'multilingual-press');
        if ('links' === $type) {
            $html = <<<HTML
<div class="mlp-quicklinks mlp-quicklink-links {$position} mlp_quicklinks mlp_quicklinks_links">
\t<div class="{$class_inner}">
\t\t{$label_text}<br>
\t\t{$selections}
\t</div>
</div>
HTML;
        } else {
            $home_url = home_url();
            $home_url = esc_attr($home_url);
            $select_id = 'mlp-quicklink-select';
            $select_name = 'mlp_quicklink_select';
            $submit_text = esc_attr_x('Go', 'quicklink submit button', 'multilingual-press');
            $html = <<<HTML
<form action="{$home_url}" method="post" class="mlp-quicklinks mlp-quicklink-form {$position} mlp_quicklinks mlp_quicklinks_form">
\t<div class="{$class_inner}">
\t\t<label for="{$select_id}">
\t\t\t{$label_text}
\t\t\t<select name="{$select_name}" id="{$select_id}" autocomplete="off">
\t\t\t\t{$selections}
\t\t\t</select>
\t\t</label>
\t\t<input type="submit" value="{$submit_text}">
\t</div>
</form>
HTML;
            $this->asset_manager->enqueue_script('multilingualpress');
        }
        /**
         * Filters the quicklinks HTML.
         *
         * @param string $html       HTML output.
         * @param string $type       Quicklink type, 'links' or 'form'.
         * @param array  $translated Array of translated posts.
         * @param string $selections Selections, 'option' or 'a' elements.
         * @param string $position   Quicklink position.
         */
        return (string) apply_filters('mlp_quicklinks_html', $html, $type, $translated, $selections, $position);
    }