Wordpress Job Manager搜索英雄小部件按钮重定向

时间:2018-10-16 08:55:54

标签: php wordpress plugins widget wordpress-theming

我正在修改wordpress主题“ jobify”。在他们的demo中,他们有一个带有按钮的“搜索英雄”小部件,可将您带到工作清单页面。检查chrome:

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

使用按钮进入其“查找工作”页面,其中包含我不想要的Google地图。因此,我创建了一个新的[jobs]页面,我将其命名为'job-search',但没有地图。如果我将上述网址编辑为chrome inspector中的网址,则该按钮会在我的新页面上正确输出搜索结果。 following this

我现在花了2天的时间浏览所有的小部件php代码,以查找将该小部件按钮上的GET命令网址从“找到工作”更改为“工作搜索”的位置。如seems straightforward

所示,在新创建的搜索页面this SO question上进行调整

我已经阅读了有关自定义其窗口小部件here的信息,并认为该文件位于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 :(得分:0)

找到解决方案(如果不是技术答案)实际上非常容易。 阅读this tutorial并看到该行之后:

$action_page_id = get_option('job_manager_jobs_page_id');

然后搜索“ job_manager_jobs_page_id”并找到this on github,发现它存在于作业管理器设置/wp-admin/edit.php?post_type=job_listing&page=job-manager-settings#settings-job_pages下从“找到工作”下拉菜单中的“工作清单”页面到新的“工作搜索”页面。一切正常。