Skip to content

Instantly share code, notes, and snippets.

View rajvanshipradeep15's full-sized avatar

Pradeep Rajvanshi rajvanshipradeep15

  • India
View GitHub Profile
<html>
<head>
<title></title>
</head>
<body>
This is my gist file
This is what I added on second edit.
</body>
</html>
@rajvanshipradeep15
rajvanshipradeep15 / PHP 1
Created May 13, 2013 12:32
joomla: select all checkboxes
<input type="checkbox" onclick="selectAll(this)" title="Check All" value="" name="sAll">
@rajvanshipradeep15
rajvanshipradeep15 / gist:5568019
Created May 13, 2013 12:35
joomla: jtoolbar custom
public function sendEmail_toolbar()
{
JToolBarHelper::custom('sendEmail', 'send.png', 'send.png', 'Send', false, false );
}
@rajvanshipradeep15
rajvanshipradeep15 / del_file.php
Created May 16, 2013 12:32
php: delete file if exists more than 3 hrs
<?php
//Delete file if it exists for more than 3 hrs
$path = $_SERVER['DOCUMENT_ROOT']."/delete_test_files";
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && preg_match('/.*.ps/i', $entry)) {
$last_modified = filemtime($path .'/' . $entry);
$last_modified_str = date("Y-m-d H:i:s", $last_modified);
@rajvanshipradeep15
rajvanshipradeep15 / getpages
Created May 21, 2013 09:52
wordpress: get_pages
<?php
$pages = get_pages();
?>
<?php $count = 1; ?>
<div class="span12">
<?php
foreach ( $pages as $page ) {
$page_link = get_page_link( $page->ID );
$title = $page->post_title;
?>
<?php
$uploadpath = $_SERVER['DOCUMENT_ROOT']."/useruploads";
$allowedExts = array("gif", "jpeg", "jpg", "png");
$extension = end(explode(".", $_FILES["upload"]["name"]));
if ((($_FILES["upload"]["type"] == "image/gif")
|| ($_FILES["upload"]["type"] == "image/jpeg")
|| ($_FILES["upload"]["type"] == "image/jpg")
|| ($_FILES["upload"]["type"] == "image/pjpeg")
|| ($_FILES["upload"]["type"] == "image/x-png")
@rajvanshipradeep15
rajvanshipradeep15 / timthumb.php
Created May 22, 2013 10:18
wordpress: image resize timthumb
<?php
/**
* TimThumb by Ben Gillbanks and Mark Maunder
* Based on work done by Tim McDaniels and Darren Hoyt
* http://code.google.com/p/timthumb/
*
* GNU General Public License, version 2
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Examples and documentation available on the project homepage
@rajvanshipradeep15
rajvanshipradeep15 / using timthumb
Created May 22, 2013 10:49
wordpress: using timthumb example
<div class="span3 " id="<?php echo $post->ID; ?>">
<div class="" style="margin-left:0px;">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="postimg" id="img_<?php echo $post->ID; ?>">
<?php
if(has_post_thumbnail()) { ?>
<?php //echo get_the_post_thumbnail($post->ID, array(255,90)); ?>
<img src="<?php bloginfo('template_directory'); ?>/wp-content/themes/mytheme1/timthumb.php?src=<?php echo get_image_url(); ?>&amp;h=90&amp;w=255&amp;zc=1" alt="<?php the_title(); ?>"/>
<?php } else {
echo '<img src="'.get_bloginfo("template_url").'/images/nothumb.jpg" alt="No Thumbnail"/>';
@rajvanshipradeep15
rajvanshipradeep15 / truncatewords
Created May 22, 2013 10:50
wordpress: truncatewords
function truncateWords($text, $maxLength = 15)
{
// explode the text into an array of words
$wordArray = explode(' ', $text);
// do we have too many?
if( sizeof($wordArray) > $maxLength )
{
// remove the unwanted words
$wordArray = array_slice($wordArray, 0, $maxLength);
@rajvanshipradeep15
rajvanshipradeep15 / featured posts
Created May 23, 2013 09:47
wordpress: to query featured posts