Beispiel #1
0
function listable_add_lwa_modal_in_footer()
{
    if (listable_using_lwa() && !is_user_logged_in()) {
        echo '<div id="lwa-modal-holder">' . listable_lwa_modal() . '</div>';
        ?>

		<script type="text/javascript">
			jQuery( document ).ready( function( $ ) {
				// use $(window).load() to make sure that we are running after LWA's script has finished doing it's thing
				$(window).load(function() {
					//We need to fix the LWA's data binding between login links and modals
					// since we will not pe outputting one modal markup per link,
					// but a single one in the footer
					// all the lwa modal links on the page will use the same markup
					var $the_lwa_login_modal = $('.lwa-modal').first();
					$('.lwa-links-modal').each(function (i, e) {
						$(e).parents('.lwa').data('modal', $the_lwa_login_modal);
					});
				});
			});
		</script>

	<?php 
    }
}
Beispiel #2
0
<?php 
} else {
    $account_required = job_manager_user_requires_account();
    $registration_enabled = job_manager_enable_registration();
    $generate_username_from_email = job_manager_generate_username_from_email();
    $login_url = listable_get_login_url();
    $classes = listable_get_login_link_class('button');
    ?>
	<fieldset>
		<label><?php 
    _e('Have an account?', 'wp-job-manager');
    ?>
</label>
		<div class="field account-sign-in <?php 
    echo listable_using_lwa() ? 'lwa' : '';
    ?>
">
			<a class="<?php 
    echo $classes;
    ?>
" href="<?php 
    echo apply_filters('submit_job_form_login_url', $login_url);
    ?>
"><?php 
    _e('Sign in', 'wp-job-manager');
    ?>
</a>

			<?php 
    if ($registration_enabled) {
Beispiel #3
0
 /**
  * Start the element output.
  *
  * @see Walker::start_el()
  *
  * @since 3.0.0
  * @since 4.4.0 'nav_menu_item_args' filter was added.
  *
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $item   Menu item data object.
  * @param int    $depth  Depth of menu item. Used for padding.
  * @param array  $args   An array of arguments. @see wp_nav_menu()
  * @param int    $id     Current item ID.
  */
 public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     if (isset($item->url) && 'custom' == $item->type) {
         if ('#listablecurrentusername' == $item->url) {
             //add a special class just for it
             $classes[] = 'menu-item-current-username ';
             if (!is_user_logged_in() && listable_using_lwa()) {
                 $classes[] = 'lwa';
             }
         } elseif ('#listablelogin' == $item->url && listable_using_lwa()) {
             $classes[] = 'lwa';
         }
     }
     /**
      * Filter the arguments for a single nav menu item.
      *
      * @since 4.4.0
      *
      * @param array  $args  An array of arguments.
      * @param object $item  Menu item data object.
      * @param int    $depth Depth of menu item. Used for padding.
      */
     $args = (object) apply_filters('nav_menu_item_args', $args, $item, $depth);
     /**
      * Filter the CSS class(es) applied to a menu item's list item element.
      *
      * @since 3.0.0
      * @since 4.1.0 The `$depth` parameter was added.
      *
      * @param array  $classes The CSS classes that are applied to the menu item's `<li>` element.
      * @param object $item    The current menu item.
      * @param array  $args    An array of {@see wp_nav_menu()} arguments.
      * @param int    $depth   Depth of menu item. Used for padding.
      */
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth));
     $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
     /**
      * Filter the ID applied to a menu item's list item element.
      *
      * @since 3.0.1
      * @since 4.1.0 The `$depth` parameter was added.
      *
      * @param string $menu_id The ID that is applied to the menu item's `<li>` element.
      * @param object $item    The current menu item.
      * @param array  $args    An array of {@see wp_nav_menu()} arguments.
      * @param int    $depth   Depth of menu item. Used for padding.
      */
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
     $id = $id ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $class_names . '>';
     $atts = array();
     $atts['title'] = !empty($item->attr_title) ? $item->attr_title : '';
     $atts['target'] = !empty($item->target) ? $item->target : '';
     $atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
     $atts['href'] = !empty($item->url) ? $item->url : '';
     $atts['class'] = ' ';
     /**
      * Filter the HTML attributes applied to a menu item's anchor element.
      *
      * @since 3.6.0
      * @since 4.1.0 The `$depth` parameter was added.
      *
      * @param array $atts {
      *     The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
      *
      *     @type string $title  Title attribute.
      *     @type string $target Target attribute.
      *     @type string $rel    The rel attribute.
      *     @type string $href   The href attribute.
      * }
      * @param object $item  The current menu item.
      * @param array  $args  An array of {@see wp_nav_menu()} arguments.
      * @param int    $depth Depth of menu item. Used for padding.
      */
     $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             //Custom URL for the Current Username menu item since right now it should be #listablecurrentusername
             if (isset($item->url) && 'custom' == $item->type) {
                 // Set up listable current user menu links
                 switch ($item->url) {
                     case '#listablecurrentusername':
                         if ('href' === $attr) {
                             $username_url = '#';
                             if (!is_user_logged_in()) {
                                 $username_url = wp_login_url();
                             } elseif (get_option('woocommerce_myaccount_page_id')) {
                                 $username_url = get_permalink(get_option('woocommerce_myaccount_page_id'));
                             }
                             $value = $username_url;
                         } elseif ('class' === $attr) {
                             if (listable_using_lwa()) {
                                 if (!is_user_logged_in()) {
                                     $value .= ' lwa-links-modal';
                                 }
                                 $value .= ' lwa-login-link';
                             } else {
                                 $value .= ' iframe-login-link';
                             }
                         }
                         break;
                     case '#listablelogin':
                         if ('href' === $attr) {
                             $value = wp_login_url();
                         } elseif ('class' === $attr) {
                             if (listable_using_lwa()) {
                                 if (!is_user_logged_in()) {
                                     $value .= ' lwa-links-modal';
                                 }
                                 $value .= ' lwa-login-link';
                             } else {
                                 $value .= ' iframe-login-link';
                             }
                         }
                         break;
                     case '#listablelogout':
                         if ('href' === $attr) {
                             $value = wp_logout_url(home_url());
                         } elseif ('class' === $attr) {
                             $value .= ' logout-link';
                         }
                         break;
                     default:
                         break;
                 }
             }
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     /** This filter is documented in wp-includes/post-template.php */
     $title = apply_filters('the_title', $item->title, $item->ID);
     /**
      * Filter a menu item's title.
      *
      * @since 4.4.0
      *
      * @param string $title The menu item's title.
      * @param object $item  The current menu item.
      * @param array  $args  An array of {@see wp_nav_menu()} arguments.
      * @param int    $depth Depth of menu item. Used for padding.
      */
     $title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth);
     $item_output = '';
     if (isset($args->before)) {
         $item_output = $args->before;
     }
     $item_output .= '<a' . $attributes . '>';
     //If this is a Current Username item
     if (isset($item->url) && 'custom' == $item->type && '#listablecurrentusername' == $item->url) {
         //Get the current user display name
         global $current_user;
         get_currentuserinfo();
         $avatar_args = array('class' => 'user-avatar');
         $avatar = get_avatar($current_user->ID, 32, '', '', $avatar_args);
         $item_output .= $avatar;
         if (!empty($current_user->display_name)) {
             $item_output .= '<span class="user-display-name">' . $current_user->display_name . '</span>';
         } else {
             $item_output .= '<span class="user-display-name">' . $item->title . '</span>';
         }
     } else {
         //do the regular WP thing
         $item_output .= $args->link_before . $title . $args->link_after;
     }
     $item_output .= '</a>';
     if (isset($args->after)) {
         $item_output .= $args->after;
     }
     /**
      * Filter a menu item's starting output.
      *
      * The menu item's starting output only includes `$args->before`, the opening `<a>`,
      * the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
      * no filter for modifying the opening and closing `<li>` for a menu item.
      *
      * @since 3.0.0
      *
      * @param string $item_output The menu item's starting HTML output.
      * @param object $item        Menu item data object.
      * @param int    $depth       Depth of menu item. Used for padding.
      * @param array  $args        An array of {@see wp_nav_menu()} arguments.
      */
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
<div class="job-manager-form action--favorite  action  wp-job-manager-bookmarks-form<?php 
if (listable_using_lwa()) {
    echo ' lwa';
}
?>
">
	<span class="action__icon">
		<?php 
get_template_part('assets/svg/add-to-favorites-icon-svg');
?>
	</span>
	<?php 
$url = listable_get_login_url();
if (!empty($url)) {
    ?>
	<a class="<?php 
    echo listable_get_login_link_class('action__text');
    ?>
" href="<?php 
    echo $url;
    ?>
">
		<?php 
    printf(esc_html__('Add to favorites', 'listable'), $post_type->labels->singular_name);
    ?>
	</a>
	<a class="<?php 
    echo listable_get_login_link_class('action__text--mobile');
    ?>
" href="<?php 
    echo $url;
Beispiel #5
0
    public function widget($args, $instance)
    {
        global $post;
        $placeholders = $this->get_placeholder_strings();
        //only put in the default title if the user hasn't saved anything in the database e.g. $instance is empty (as a whole)
        $title = apply_filters('widget_title', empty($instance) || !isset($instance['title']) ? $placeholders['title'] : $instance['title'], $instance, $this->id_base);
        $claim_button_text = empty($instance) || !isset($instance['claim_button_text']) ? $placeholders['claim_button_text'] : $instance['claim_button_text'];
        $claim_description_text = empty($instance) || !isset($instance['claim_description_text']) ? $placeholders['claim_description_text'] : $instance['claim_description_text'];
        $classes = WP_Job_Manager_Claim_Listing()->listing->add_post_class(array());
        if (isset($classes[0]) && !empty($classes[0])) {
            if ($classes[0] == 'claimed') {
                return;
            }
        }
        echo $args['before_widget'];
        if (!empty($title) || !empty($claim_button_text)) {
            //make sure that Login with Ajax can work
            if (empty($paid_claims) && !is_user_logged_in() && listable_using_lwa()) {
                //we need a wrapper with the lwa class
                $args['before_title'] .= '<div class="lwa">';
                $args['after_title'] = '</div>' . $args['after_title'];
            }
            echo $args['before_title'] . $title;
            if (!empty($claim_button_text)) {
                $paid_claims = get_option('wpjmcl_paid_claiming');
                $paid_claim_listing_page = job_manager_get_permalink('claim_listing');
                $href = esc_url(wp_nonce_url(add_query_arg(array('action' => 'claim_listing', 'listing_id' => $post->ID), $paid_claim_listing_page), 'claim_listing', 'claim_listing_nonce'));
                $classes = 'listing-claim-button';
                if (empty($paid_claims) && !is_user_logged_in()) {
                    $href = listable_get_login_url();
                    $classes = listable_get_login_link_class($classes);
                }
                echo ' <a class="' . $classes . '" href="' . $href . '">' . $claim_button_text . '</a>';
            }
            echo $args['after_title'];
        }
        if (!empty($claim_description_text)) {
            echo '<small class="listing-claim-description">' . $claim_description_text . '</small>';
        }
        wc_print_notices();
        ?>

		<?php 
        echo $args['after_widget'];
    }