示例#1
0
        if (!empty($this->parts_of_speech)) {
            return;
        }
        $this->parts_of_speech = array('noun' => _x('noun', 'part-of-speech', 'glotpress'), 'verb' => _x('verb', 'part-of-speech', 'glotpress'), 'adjective' => _x('adjective', 'part-of-speech', 'glotpress'), 'adverb' => _x('adverb', 'part-of-speech', 'glotpress'), 'interjection' => _x('interjection', 'part-of-speech', 'glotpress'), 'conjunction' => _x('conjunction', 'part-of-speech', 'glotpress'), 'preposition' => _x('preposition', 'part-of-speech', 'glotpress'), 'pronoun' => _x('pronoun', 'part-of-speech', 'glotpress'), 'expression' => _x('expression', 'part-of-speech', 'glotpress'));
    }
    /**
     * Sets restriction rules for fields.
     *
     * @since 1.0.0
     *
     * @param GP_Validation_Rules $rules The validation rules instance.
     */
    public function restrict_fields($rules)
    {
        $rules->term_should_not_be('empty');
        $rules->part_of_speech_should_not_be('empty');
        $rules->glossary_id_should_be('positive_int');
        $rules->last_edited_by_should_be('positive_int');
    }
    public function by_glossary_id($glossary_id)
    {
        return $this->many("SELECT * FROM {$this->table} WHERE glossary_id= %d ORDER by term ASC", $glossary_id);
    }
    public function last_modified($glossary)
    {
        global $wpdb;
        return $wpdb->get_var($wpdb->prepare("SELECT date_modified FROM {$this->table} WHERE glossary_id = %d ORDER BY date_modified DESC LIMIT 1", $glossary->id, 'current'));
    }
}
GP::$glossary_entry = new GP_Glossary_Entry();