28 июля 2012
Нет комментариев
<?php echo do_shortcode('[contact-form-7 id="259" title="Форма для контакта 1"]'); ?>
<?php echo do_shortcode('[contact-form-7 id="259" title="Форма для контакта 1"]'); ?>
Изменение БД:
Добавляем поля в таблицу wp_posts
Добавление полей в форму редактирования записи:
/wp-admin/edit-form-advanced.php
например после div с заголовком:
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
Сохранение указанных значений:
/wp-includes/post.php
изменения вносятся в функцию wp_insert_post
(добавляем свои поля в массив)
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
$arr = array(2, 3, 4, 2, 5, 2); function delEl($arr, $del) { foreach($arr as $val) { if($val !== $del) $newArr[] = $val; } return $newArr; } // Пример $checkDelEl = delEl($arr, 2); print_r($checkDelEl); // Array ( [0] => 3 [1] => 4 [2] => 5 )
src всех изображений:
preg_match_all('/<img[^>]+src=([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/',$content,$matches); print_r($matches[2]);
Как пример:
if ($matches[2][0]!='') { echo "<img src='".$matches[2][0]."' alt=''/>"; }
Получить домен из URL:
parse_url($url,PHP_URL_HOST)
На примере SELECT. Если одно поле:
$getdb=&JFactory::getDBO(); $q="SELECT mfo FROM jos_users WHERE mfo!='0'"; $getdb->setQuery($q); $arr=$getdb->loadResultArray();
Если много:
$q="SELECT username, mfo FROM jos_users WHERE mfo!='0'"; $arr=$getdb->loadObjectList(); foreach ($arr as $a) { $mfo=$a->mfo; $username=$a->username; }
$j_user=&JFactory::getUser(); $user_mfo=$j_user->mfo;