WordPress Job Manager перенаправление кнопки виджета героя поиска - PullRequest
0 голосов
/ 16 октября 2018

Я изменяю тему WordPress «Jobify».В их демо есть виджет «Поиск героя» с кнопкой, которая ведет вас на страницу со списком вакансий.Проверка в chrome:

<form class="job_search_form job_search_form--flat" 
action="https://jobify-demos.astoundify.com/classic/find-a-job/" 
method="GET">

На их странице 'найди работу', на которую ты попадаешь с помощью кнопки, есть карты Google, которые мне не нужны.Поэтому я создал новую страницу [вакансии], которую я назвал «поиск работы» без карты.Если я отредактирую приведенный выше URL-адрес в Chrome Inspector, то кнопка правильно выведет результаты поиска на мою новую страницу. после этого

Я потратил 2 дня, просматривая весь php-код виджета, пытаясь найти, где я могу изменить URL-адрес команды GET для этой кнопки виджета с 'find-a-job' на'поиск работы'.Настроить это на недавно созданной поисковой странице кажется простым , как видно на этом SO вопросе

Я читал о настройке их виджетов здесь и подумалэто будет в файле class-widget-search-hero.php (ниже).Я также проверил его файл scss, но там ничего не вижу.Так много часов в поиске, это так просто, как удалить одну из двух страниц [рабочих мест]?Спасибо.

<?php
/**
* Home: Search Hero
*
* @package Jobify
* @category Widget
* @since 3.0.0
*/
class Jobify_Widget_Search_Hero extends Jobify_Widget {

public function __construct() {
    $this->widget_description = __( 'Display a "hero" search area.', 'jobify' );
    $this->widget_id          = 'jobify_widget_search_hero';
    $this->widget_cssclass    = 'widget--home-hero-search';
    $this->widget_name        = __( 'Jobify - Page: Search Hero', 'jobify' );
    $this->control_ops        = array(
        'width' => 400,
    );
    $this->settings           = array(
        'home widgetized' => array(
            'std' => __( 'Homepage/Widgetized', 'jobify' ),
            'type' => 'widget-area',
        ),
        'height' => array(
            'type' => 'select',
            'std'  => 'medium',
            'label' => __( 'Hero Height', 'jobify' ),
            'options' => array(
                'small' => __( 'Small', 'jobify' ),
                'medium' => __( 'Medium', 'jobify' ),
                'large' => __( 'Large', 'jobify' ),
            ),
        ),
        'margin' => array(
            'type' => 'checkbox',
            'std'  => 1,
            'label' => __( 'Add standard spacing above/below widget', 'jobify' ),
        ),
        'text_color' => array(
            'type'  => 'colorpicker',
            'std'   => '#ffffff',
            'label' => __( 'Text Color:', 'jobify' ),
        ),
        'title' => array(
            'type'  => 'text',
            'std'   => '',
            'label' => __( 'Title:', 'jobify' ),
        ),
        'description' => array(
            'type'  => 'text',
            'std'   => '',
            'label' => __( 'Description:', 'jobify' ),
            'rows'  => 5,
        ),
        'image' => array(
            'type'  => 'image',
            'std'   => '',
            'label' => __( 'Background Image:', 'jobify' ),
        ),
        'background_position' => array(
            'type'  => 'select',
            'std'   => 'center center',
            'label' => __( 'Image Position:', 'jobify' ),
            'options' => array(
                'left top' => __( 'Left Top', 'jobify' ),
                'left center' => __( 'Left Center', 'jobify' ),
                'left bottom' => __( 'Left Bottom', 'jobify' ),
                'right top' => __( 'Right Top', 'jobify' ),
                'right center' => __( 'Right Center', 'jobify' ),
                'right bottom' => __( 'Right Bottom', 'jobify' ),
                'center top' => __( 'Center Top', 'jobify' ),
                'center center' => __( 'Center Center', 'jobify' ),
                'center bottom' => __( 'Center Bottom', 'jobify' ),
                'center top' => __( 'Center Top', 'jobify' ),
            ),
        ),
        'cover_overlay' => array(
            'type' => 'checkbox',
            'std'  => 1,
            'label' => __( 'Use transparent overlay', 'jobify' ),
        ),
    );

    if ( jobify()->get( 'wp-job-manager-resumes' ) ) {
        $what = array(
            'what' => array(
                'type' => 'select',
                'std' => 'job',
                'label' => __( 'Search:', 'jobify' ),
                'options' => array(
                    'job' => __( 'Jobs', 'jobify' ),
                    'resume' => __( 'Resumes', 'jobify' ),
                ),
            ),
        );

        $this->settings = $what + $this->settings;
    }

    parent::__construct();
}

function widget( $args, $instance ) {
    extract( $args );

    $text_align = isset( $instance['text_align'] ) ? esc_attr( $instance['text_align'] ) : 'left';
    $background_position = isset( $instance['background_position'] ) ? esc_attr( $instance['background_position'] ) : 'center center';
    $overlay = isset( $instance['cover_overlay'] ) && 1 == $instance['cover_overlay'] ? 'has-overlay' : 'no-overlay';
    $margin = isset( $instance['margin'] ) && 1 == $instance['margin'] ? true : false;
    $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : 'medium';

    if ( ! $margin ) {
        $before_widget = str_replace( 'widget--home ', 'widget--home widget--home--no-margin ', $before_widget );
    }

    $image = isset( $instance['image'] ) ? esc_url( $instance['image'] ) : null;
    $content = $this->assemble_content( $instance );

    $what = isset( $instance['what'] ) ? esc_attr( $instance['what'] ) : 'job';

    global $is_flat;
    $is_flat = true;

    ob_start();
    ?>

    <?php echo $before_widget; ?>

        <div class="hero-search hero-search--<?php echo esc_attr( $overlay ); ?> hero-search--height-<?php echo esc_attr( $height ); ?>" style="background-image:url(<?php echo $image; ?>); ?>; background-position: <?php echo $background_position; ?>">

        <div class="container">
            <?php echo $content; ?>

            <?php locate_template( array( $what . '-filters-flat.php' ), true, false ); ?>
        </div>

    </div>

    <?php echo $after_widget; ?>

    <?php

    $content = ob_get_clean();

    echo apply_filters( $this->widget_id, $content );
}

private function assemble_content( $instance ) {
    $text_color = isset( $instance['text_color'] ) ? esc_attr( $instance['text_color'] ) : '#fff';

    $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    $content = isset( $instance['description'] ) ? $instance['description'] : '';

    $output  = '<div class="hero-search__content" style="color:' . $text_color . '">';
    $output .= '<h2 class="hero-search__title" style="color:' . $text_color . '">' . $title . '</h2>';
    $output .= wpautop( $content );
    $output .= '</div>';

    return $output;
}

}

1 Ответ

0 голосов
/ 16 октября 2018

Решение (если не технический ответ) на самом деле было очень легко найти.Прочитав этот урок и увидев строку:

$action_page_id = get_option('job_manager_jobs_page_id');

Затем выполнив поиск "job_manager_jobs_page_id" и найдя это на github Я обнаружил, что он существует в настройках менеджера заданий /wp-admin / edit.php? post_type = job_listing & page = job-manager-settings # settings-job_pages, где вы просто меняете страницу «Списки вакансий» в раскрывающемся меню с «найти работу» на мою новую страницу «Поиск работы».Все работает.

...