开发者

php - how can i place the variables of a function into this action script?

i have the variables $test1 and $test2 below.. how can i get them to replace where you enter the site name below? im so frustrated.. i am using wordpress as a cms..

    <?php
$homepage = file_get_contents('http://www.macsiam.com/sites.php');


preg_match_all('%\'http://([^./]+).[^.]+\.[a-z]{2,4}\'%i', $homepage, $domains, PREG_PATTERN_ORDER);
// $domains[0] is an array of matched full URLs (http://whatever.wherever.com/page.php)
// $domains[1] is an array of matched subdomains (whatever)

$test1 = $domains[1][0];
$test2 = $domains[1][1];

echo $test1;
echo '<br>';
echo $test2;

?>

to

<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?>
<table class="form-table">
    <tr class="form-field form-required">
      <th scope="row"><?php _e( 'Site Address' ) ?></th>
      <td>
      <?php if ( is_subdomain_install() ) { ?>
      <input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo preg_replace( '|^www\.|', '', $current_site->domain );?>
      <?php } else {
        echo $current_site->domain . $current_site->path ?><input nam开发者_运维百科e="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>
      <?php }
      echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>';
      ?>
      </td>
    </tr>
    <tr class="form-field form-required">
      <th scope="row"><?php _e( 'Site Title' ) ?></th>
      <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td>
      </tr>
      <tr class="form-field form-required">
        <th scope="row"><?php _e( 'Admin Email' ) ?></th>
        <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td>
      </tr>
      <tr class="form-field">
        <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>
      </tr>
    </table>
    <?php submit_button( __('Add Site'), 'primary', 'add-site' ); ?>

<form method="post" action="<?php echo network_admin_url('site-new.php?action=add-site'); ?>">


I don't see where you are trying to place any of this. I don't even understand exactly what you are trying to accomplish. But I will make a few guesses here. What makes the least amount of sense is the fact that you describe both of the variables you want to substitute in as arrays (not strings) but you want to use these arrays in the place of a site name (which is commonly a string).

If you are trying to just add the variable contents to a specific place on the page then you would just create the variable and in the template echo it where you want it to go.

<div class="site-name"><?php echo $test1; ?></div>

If you actually want the site name, Wordpress has a function for that. Its called wp_title.

<div class="site-name"><?php wp_title(); ?></div>

http://codex.wordpress.org/Function_Reference/wp_title

Other than that you can wrap the output in JavaScript tags and set the value as a Javascript (JS) variable value. Then you can use JS to put it where you want it to go on the page on the fly.

If you are trying to do something else then I recommend being more specific what data A is (should end up being a string if it is going on a page directly). Give us an example of the data itself (specific, such as $title = 'My broke site';). Then show us where you want this to end up. Maybe between some divs. Maybe as a hidden form input or a form action param. If you need an array encoded onto the page then tell us how you want to use that and why it has to be on the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜