Beispiel #1
0
function wp_ozh_yourls_get_new_short_url($url, $post_id = 0)
{
    // Init plugin (redundant when in admin, needed when plugin called from public part, for instance triggered by a template tag)
    global $wp_ozh_yourls;
    if (!$wp_ozh_yourls) {
        wp_ozh_yourls_admin_init();
    }
    // Get short URL
    $shorturl = wp_ozh_yourls_api_call(wp_ozh_yourls_service(), $url);
    // Store short URL in a custom field
    if ($post_id && $shorturl) {
        update_post_meta($post_id, 'yourls_shorturl', $shorturl);
    }
    return $shorturl;
}
Beispiel #2
0
    shortener_init();
    lib_include('json');
    global $wp_ozh_yourls;
    if (!$wp_ozh_yourls) {
        wp_ozh_yourls_admin_init();
    }
    $service = wp_ozh_yourls_service();
    if (empty($service)) {
        add_option('ozh_yourls', array('service' => 'other', 'location' => '', 'yourls_path' => '', 'yourls_url' => '', 'yourls_login' => '', 'yourls_password' => '', 'rply_login' => '', 'rply_password' => '', 'other' => 'rply'));
        global $wp_ozh_yourls;
        if (!$wp_ozh_yourls) {
            wp_ozh_yourls_admin_init();
        }
        $service = wp_ozh_yourls_service();
    }
    $shorturl = wp_ozh_yourls_api_call(wp_ozh_yourls_service(), $_POST['ajax_shorten']);
    if ($shorturl) {
        echo $shorturl;
    } else {
        echo 'error';
    }
    exit;
}
after_filter('set_up_new_shortener', 'insert_from_post');
function set_up_new_shortener(&$model, &$rec)
{
    global $request;
    if (!($request->resource == 'blogs')) {
        return;
    }
    // XXX subdomain upgrade