Beispiel #1
0
function jr_mt_echo_sticky_query_entry()
{
    global $jr_mt_kwvalsep;
    $settings = get_option('jr_mt_settings');
    $three_dots = '…';
    $first = TRUE;
    if (!empty($settings['query'])) {
        foreach ($settings['query'] as $keyword => $value_array) {
            foreach ($value_array as $value => $theme) {
                if ('*' !== $value) {
                    if ($first) {
                        $first = FALSE;
                    } else {
                        echo '<br />';
                    }
                    echo 'Sticky <input type="checkbox" id="sticky_query_entry" name="jr_mt_settings[sticky_query_entry][]" value="' . "{$keyword}{$jr_mt_kwvalsep}{$value}" . '" ';
                    checked(isset($settings['remember']['query'][$keyword][$value]));
                    echo ' /> &nbsp; Override <input type="checkbox" id="override_query_entry" name="jr_mt_settings[override_query_entry][]" value="' . "{$keyword}{$jr_mt_kwvalsep}{$value}" . '" ';
                    checked(isset($settings['override']['query'][$keyword][$value]));
                    echo ' /> &nbsp; Theme=' . wp_get_theme($theme)->Name . '; ' . 'Query=' . '<code>' . JR_MT_HOME_URL . "/</code>{$three_dots}<code>/?" . "<b><input type='text' readonly='readonly' disable='disabled' name='jr_mt_stkw' value='{$keyword}' size='" . jr_mt_strlen($keyword) . "' /></b>" . '=' . "<b><input type='text' readonly='readonly' disable='disabled' name='jr_mt_stkwval' value='{$value}' size='" . jr_mt_strlen($value) . "' /></b></code>";
                }
            }
        }
    }
    if ($first) {
        echo 'None';
    }
}
Beispiel #2
0
/**
 * Make URL Relative to Site URL
 * 
 */
function jr_mt_relative_url($url, $site_url)
{
    $url_path_array = parse_url($url);
    $url_path = $url_path_array['path'];
    if (!empty($url_path_array['query'])) {
        $url_path .= '?' . $url_path_array['query'];
    }
    $site_url_path = parse_url($site_url, PHP_URL_PATH);
    return trim(jr_mt_substr($url_path, jr_mt_strlen($site_url_path)), '/\\');
}
Beispiel #3
0
/**
 * Does a specified Prefix URL match the given URL?
 * 
 * Preps URL, if string.
 * Note:  parameters MUST be in the right order
 *
 * @param    string/array  $prefix	front part of a URL to compare, a string, or an array in special format created by companion function
 * @param    string/array  $url		full URL to compare, a string, or an array in special format created by companion function
 * @return   bool					bool TRUE if Prefix matches first part of URL; FALSE otherwise
 */
function jr_mt_same_prefix_url($prefix, $url)
{
    if (is_string($prefix)) {
        $prefix = jr_mt_prep_url($prefix);
    }
    if (is_string($url)) {
        $url = jr_mt_prep_url($url);
    }
    if ($url['host'] === $prefix['host']) {
        if ($url['port'] === $prefix['port']) {
            if ($url['path'] === $prefix['path']) {
                /*	Host and Path both exactly match for URL and Prefix specified.
                 */
                if (array() === $prefix['query']) {
                    $match = TRUE;
                } else {
                    /*	Now the hard part:  determining a legitimate prefix match for Query
                     */
                    foreach ($prefix['query'] as $prefix_keyword => $prefix_value) {
                        $one_match = FALSE;
                        foreach ($url['query'] as $url_keyword => $url_value) {
                            if ($prefix_keyword === jr_mt_substr($url_keyword, 0, jr_mt_strlen($prefix_keyword))) {
                                if ($prefix_value === jr_mt_substr($url_value, 0, jr_mt_strlen($prefix_value))) {
                                    $one_match = TRUE;
                                }
                            }
                        }
                        /*	All Prefix Queries must match.
                         */
                        if (FALSE === $one_match) {
                            return FALSE;
                        }
                    }
                    $match = TRUE;
                }
            } else {
                /*	Paths must exactly match if Prefix specifies Query
                 */
                if (array() === $prefix['query']) {
                    /*	No Query in Prefix, so check Path for Prefix match
                     */
                    $match = $prefix['path'] === jr_mt_substr($url['path'], 0, jr_mt_strlen($prefix['path']));
                } else {
                    $match = FALSE;
                }
            }
        } else {
            /*	Perhaps unnecessary restriction:
            				If Hosts match, then so much Ports.
            			*/
            $match = FALSE;
        }
    } else {
        if (0 === $prefix['port'] && '' === $prefix['path'] && array() === $prefix['query']) {
            /*	No Path or Query in Prefix, so check Host for Prefix match
             */
            $match = $prefix['host'] === jr_mt_substr($url['host'], 0, jr_mt_strlen($prefix['host']));
        } else {
            /*	Hosts must exactly match if Prefix specifies Path or Query
             */
            $match = FALSE;
        }
    }
    return $match;
}