예제 #1
0
/**
 * Executes changes made in HiveQueen 0.0.1.
 *
 * @since 0.0.1
 *
 * @global int  $hq_current_db_version Current version.
 * @global hqdb $hqdb                  HiveQueen database abstraction object.
 */
function upgrade_430()
{
    global $hq_current_db_version, $hqdb;
    if ($hq_current_db_version < 32364) {
        upgrade_430_fix_comments();
    }
    // Shared terms are split in a separate process.
    if ($hq_current_db_version < 32814) {
        update_option('finished_splitting_shared_terms', 0);
        hq_schedule_single_event(time() + 1 * MINUTE_IN_SECONDS, 'hq_split_shared_term_batch');
    }
    if ($hq_current_db_version < 33055 && 'utf8mb4' === $hqdb->charset) {
        if (is_multisite()) {
            $tables = $hqdb->tables('blog');
        } else {
            $tables = $hqdb->tables('all');
            if (!hq_should_upgrade_global_tables()) {
                $global_tables = $hqdb->tables('global');
                $tables = array_diff_assoc($tables, $global_tables);
            }
        }
        foreach ($tables as $table) {
            maybe_convert_table_to_utf8mb4($table);
        }
    }
}
예제 #2
0
/**
 * Handle importer uploading and add attachment.
 *
 * @since 0.0.1
 *
 * @return array Uploaded file's details on success, error message on failure
 */
function hq_import_handle_upload()
{
    if (!isset($_FILES['import'])) {
        return array('error' => __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.'));
    }
    $overrides = array('test_form' => false, 'test_type' => false);
    $_FILES['import']['name'] .= '.txt';
    $upload = hq_handle_upload($_FILES['import'], $overrides);
    if (isset($upload['error'])) {
        return $upload;
    }
    // Construct the object array
    $object = array('post_title' => basename($upload['file']), 'post_content' => $upload['url'], 'post_mime_type' => $upload['type'], 'guid' => $upload['url'], 'context' => 'import', 'post_status' => 'private');
    // Save the data
    $id = hq_insert_attachment($object, $upload['file']);
    /*
     * Schedule a cleanup for one day from now in case of failed
     * import or missing hq_import_cleanup() call.
     */
    hq_schedule_single_event(time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array($id));
    return array('file' => $upload['file'], 'id' => $id);
}
예제 #3
0
파일: post.php 프로젝트: gcorral/hivequeen
/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * Uses XMLRPC_REQUEST and HQ_IMPORTING constants.
 *
 * @since 0.0.1
 * @access private
 *
 * @param int $post_id The ID in the database table of the post being published.
 */
function _publish_post_hook($post_id)
{
    if (defined('XMLRPC_REQUEST')) {
        /**
         * Fires when _publish_post_hook() is called during an XML-RPC request.
         *
         * @since 0.0.1
         *
         * @param int $post_id Post ID.
         */
        do_action('xmlrpc_publish_post', $post_id);
    }
    if (defined('HQ_IMPORTING')) {
        return;
    }
    if (get_option('default_pingback_flag')) {
        add_post_meta($post_id, '_pingme', '1');
    }
    add_post_meta($post_id, '_encloseme', '1');
    hq_schedule_single_event(time(), 'do_pings');
}