/*
rule_match_post_status

@description:
@since: 3.5.7
@created: 3/01/13
767938
function rule_match_post_status( $match, $rule, $options )
	{
		// validate
		if( !$options['post_id'] )
		{
			return false;
		}
		
					
		// vars
		$post_status = get_post_status( $options['post_id'] );
	    
	    
	    // auto-draft = draft
	    if( $post_status == 'auto-draft' )
	    {
		    $post_status = 'draft';
	    }
	    
	    
	    // match
	    if($rule['operator'] == "==")
        {
        	$match = ( $post_status === $rule['value'] );
        	 
        }
        elseif($rule['operator'] == "!=")
        {
        	$match = ( $post_status !== $rule['value'] );
        }
        
        
        // return
	    return $match;
        
    }
1288520
def gen_post_status():
    

    if not app.config["DEBUG"]:
        post_status = and_(Post.status == PostStatus.PUBLISH)
    else:
        post_status = or_(Post.status == PostStatus.PUBLISH,
                          Post.status == PostStatus.DRAFT)
    return post_status
950333
function checkPositionAndRule( nodeA, nodeB, def, posBitFlags ) {
		return ( nodeA.getPosition( nodeB ) | posBitFlags ) == posBitFlags &&
			( !def.childRule || def.childRule( nodeA ) );
	}
1367811
private List<Rule> match(final RuleSet ruleSet, final OgnlContext ognlContext) throws OgnlException
	{
		log.debug("Assessing input for ruleset : " + ruleSet.id);

		//run the input commands
		ruleSet.runInput(ognlContext);

		final List<Rule> ret = new ArrayList<>();

		//assess each rule against the input, return any that match
		for (Rule rule : ruleSet.rules)
		{
			Boolean bresult = rule.assessMatch(ognlContext);

			if (bresult)
			{
				log.debug(rule.condition.getOriginalExpression() + " matches");
				ret.add(rule);
			}
		}

		return ret;
	}
820033
function(str, pattern)
	{
		// LATER: Check is this can be done with a regular expression
		var postfix = '';
		
		while (str.length > 0 && str.charAt(str.length - 1) == '\n')
		{
			str = str.substring(0, str.length - 1);
			postfix += pattern;
		}
		
		return str + postfix;
	}
1205381
function applyDisallowedRule( rule, element, status ) {
		// This rule doesn't match this element - skip it.
		if ( rule.match && !rule.match( element ) )
			return;

		// No properties - it's an element only rule so it disallows entire element.
		// Early return is handled in filterElement.
		if ( rule.noProperties )
			return false;

		// Apply rule to attributes, styles and classes. Switch hadInvalid* to true if method returned true.
		status.hadInvalidAttribute = applyDisallowedRuleToHash( rule.attributes, element.attributes ) || status.hadInvalidAttribute;
		status.hadInvalidStyle = applyDisallowedRuleToHash( rule.styles, element.styles ) || status.hadInvalidStyle;
		status.hadInvalidClass = applyDisallowedRuleToArray( rule.classes, element.classes ) || status.hadInvalidClass;
	}
201018
def obtain_article_status(check = nil)
      article = 
        if check.blank? && !@content.blank? && @content[0].blank?
          @content
        else
          obtain_record(check, 'page')
        end
      !article.blank? && article.has_attribute?('post_status') ? article.post_status : nil
    end
209743
function(rule, callback){
        var res = [];
        callback = callback || function(){};
        this.each(function(item){
            var pass = true;
            if(pass && rule.group != undefined){
                pass = rule.group == item.parent;
            }
            if(pass && rule.type != undefined){
                pass = rule.type == item.type;
            }
            if(item.type == 'ip'){
                if(pass && rule.ip != undefined){
                    pass = rule.ip == item.ip;
                }
                if(pass && rule.domain != undefined){
                    pass = rule.domain == item.domain;
                }
                if(pass && rule.enable != undefined){
                    pass = rule.enable == item.enable;
                }
                if(pass && rule.comment != undefined){
                    pass = rule.comment == item.comment;
                }
            }else if(item.type == 'text'){
                if(pass && rule.text != undefined){
                    pass = rule.text == item.text;
                }
            }
            if(pass){
                callback.call(item, item);
                res.push(item);
            }
        });
        return res;
    }
1101990
function statusValid (xhr) {
	try {
		var status = xhr.status
		return (status !== null && status !== 0)
	} catch (e) {
		return false
	}
}
1309273
function rule_match_ef_user( $match, $rule, $options )
	{
	
		$ef_user = $options['ef_user'];
		
		
		if( $ef_user )
		{
			if($rule['operator'] == "==")
	        {
	        	$match = ( user_can($ef_user, $rule['value']) );
	        	
	        	// override for "all"
		        if( $rule['value'] === "all" )
				{
					$match = true;
				}
	        }
	        elseif($rule['operator'] == "!=")
	        {
	        	$match = ( !user_can($ef_user, $rule['value']) );
	        	
	        	// override for "all"
		        if( $rule['value'] === "all" )
				{
					$match = false;
				}
	        }

		}
		
        
        return $match;
        
    }
425574
public function save_post_detect_new( $new_status, $old_status, $post ) {

		if ( $post ) {
			self::$old_post_status[ $post->post_type ] = $old_status;
		}

	}
654621
function rule_match_page_type( $match, $rule, $options )
	{
		// validation
		if( !$options['post_id'] )
		{
			return false;
		}

		$post = get_post( $options['post_id'] );
		        
        if( $rule['value'] == 'front_page')
        {
        	
	        $front_page = (int) get_option('page_on_front');
	        
	        
	        if($rule['operator'] == "==")
	        {
	        	$match = ( $front_page == $post->ID );
	        }
	        elseif($rule['operator'] == "!=")
	        {
	        	$match = ( $front_page != $post->ID );
	        }
	        
        }
        elseif( $rule['value'] == 'posts_page')
        {
        
	        $posts_page = (int) get_option('page_for_posts');
	        
	        
	        if($rule['operator'] == "==")
	        {
	        	$match = ( $posts_page == $post->ID );
	        }
	        elseif($rule['operator'] == "!=")
	        {
	        	$match = ( $posts_page != $post->ID );
	        }
	        
        }
        elseif( $rule['value'] == 'top_level')
        {
        	$post_parent = $post->post_parent;
        	if( $options['page_parent'] )
        	{
	        	$post_parent = $options['page_parent'];
        	}
        	
        	
	        if($rule['operator'] == "==")
	        {
	        	$match = ( $post_parent == 0 );
	        }
	        elseif($rule['operator'] == "!=")
	        {
	        	$match = ( $post_parent != 0 );
	        }
	        
        }
        elseif( $rule['value'] == 'parent')
        {
        
        	$children = get_pages(array(
        		'post_type' => $post->post_type,
        		'child_of' =>  $post->ID,
        	));
        	
	        
	        if($rule['operator'] == "==")
	        {
	        	$match = ( count($children) > 0 );
	        }
	        elseif($rule['operator'] == "!=")
	        {
	        	$match = ( count($children) == 0 );
	        }
	        
        }
        elseif( $rule['value'] == 'child')
        {
        
        	$post_parent = $post->post_parent;
        	if( $options['page_parent'] )
        	{
	        	$post_parent = $options['page_parent'];
        	}
	        
	        
	        if($rule['operator'] == "==")
	        {
	        	$match = ( $post_parent != 0 );
	        }
	        elseif($rule['operator'] == "!=")
	        {
	        	$match = ( $post_parent == 0 );
	        }
	        
        }
        
        return $match;

	}
671825
function PostmarkErrorStatus(response) {
  MessagingServiceStatus.call(this, 'postmark');

  // There was an error when attempting to send message
  this.state.message = response.code + ': ' + response.message;

  // Catch internal server error
  if (response.status == 500) {
    this.state.code = this.StatusCodes.SERVICE_DOWN;
    return
  }

  // See http://developer.postmarkapp.com/developer-api-overview.html for status error codes
  if (response.code == 400) this.state.code = this.StatusCodes.DATA_REJECTED;
  else if (response.code == 401) this.state.code = this.StatusCodes.DATA_REJECTED;
  else if (response.code == 405) this.state.code = this.StatusCodes.LIMIT_EXCEEDED;
  else if (response.code == 406) this.state.code = this.StatusCodes.DATA_REJECTED;
  else if (response.code == 507) this.state.code = this.StatusCodes.DATA_REJECTED;
  else if (response.code == 522) this.state.code = this.StatusCodes.DATA_REJECTED;
  else this.state.code = this.StatusCodes.DEFAULT;
}
592775
def is_matching_rule(self, request):
		""""""
		# First, if in DEBUG mode and with django-debug-toolbar, we skip
		#   this entire process.
		if settings.DEBUG and request.path.startswith("/__debug__"):
			return True

		# Second we check against matches
		match = resolve(request.path, getattr(request, "urlconf", settings.ROOT_URLCONF))
		if "({0})".format(match.app_name) in EXEMPT:
			return True

		if "[{0}]".format(match.namespace) in EXEMPT:
			return True

		if "{0}:{1}".format(match.namespace, match.url_name) in EXEMPT:
			return True

		if match.url_name in EXEMPT:
			return True

		# Third, we check wildcards:
		for exempt in [x for x in EXEMPT if x.startswith("fn:")]:
			exempt = exempt.replace("fn:", "")
			if fnmatch.fnmatch(request.path, exempt):
				return True

		return False
237575
function filterAfter(posts) {
      after = moment(after.replace(/\//g, '-'), 'MM-DD-YYYY', true);
      if (!after.isValid()) {
        console.log(chalk.red('After date is not valid (expecting `MM-DD-YYYY`), ignoring argument.'));
        return posts;
      }

      return posts.filter(function filterPosts(post) {
        return moment(post.date).isAfter(after);
      });
    }
1263031
protected function check_is_post_type_allowed( $post_type ) {
		if ( ! is_object( $post_type ) ) {
			$post_type = get_post_type_object( $post_type );
		}

		if ( ! empty( $post_type ) && ! empty( $post_type->show_in_rest ) ) {
			return true;
		}

		return false;
	}
542511
function getPostIntro(body) {
  let isBlankReg = /^\s+$/,
    start = 0;
  return body.split('\n').filter((item) => {
    if (start < 5 && !isBlankReg.test(item)) {
      start++;
      return true;
    }
  }).join('\n')
}