Wednesday, January 28, 2015

Redirecting page by js

<a href="http://ashique12009.files.wordpress.com/2011/06/js.jpg"><img src="http://ashique12009.files.wordpress.com/2011/06/js.jpg" alt="" title="js" width="157" height="127" class="alignnone size-full wp-image-24" /></a>
<strong>this works fine for every browser</strong>
<strong>window.location.href='url';</strong>

PHP 1 page solution...

you can use hidden variable to post something on same page without not going to another page...i'll show you later...

One tricky infinity time animation by jquery

$(document).ready(function(){
$.fn.grow_anim=function(){
$("#anim").animate({paddingLeft: "100px"}, 1000);
$(this).shrink_anim();
}

$.fn.shrink_anim=function(){
$("#anim").animate({paddingLeft: "15px"}, 1000);
$(this).grow_anim();
}

$("#anim").bind("mouseenter",function(){
$("#anim").stop(true);
});

$("#anim").bind("mouseleave",function(){
$(this).grow_anim();
});
});

I am explaining below:

Normally animation running and running but when you put your mouse on that Div or text in that time animation will be stop then again when you leave your mouse pointer from that div or text your animation will be running normally.

try it good luck.

Maximum Css Hack Tools

<strong>IE7</strong>= *attribute:value;
<strong>IE8</strong>= attribute/*\**/:value\9;
<strong>IE9</strong>= watch out below -&gt;

<a href="http://ashique12009.files.wordpress.com/2011/06/ie9.png"><img class="alignnone size-full wp-image-36" title="ie9" src="http://ashique12009.files.wordpress.com/2011/06/ie9.png" alt="" width="203" height="25" /></a>

/************************************************/
<strong>opera</strong>
@media all and (-webkit-min-device-pixel-ratio:10000), not all and
(-webkit-min-device-pixel-ratio:0) {
css goes here
}
/************************************************/
/************************************************/
<strong>safari and google crome</strong>
@media screen and (-webkit-min-device-pixel-ratio:0){
css goes here
}
/************************************************/

Add copy paste and delete button in windows 7 menu bar

<font color="red"><b>Step 1:</b></font>
go to run and type regedit.
<font color="red"><b>Step 2:</b></font>
go to
HKEY_LOCAL_MACHINE -&gt;
Software -&gt;
Microsoft -&gt;
Windows -&gt;
CurrentVersion -&gt;
Explorer -&gt;
FolderTypes -&gt;
{5c4f28b5-f869-4e84-8e60-f11db97c5cc7} .
<font color="red"><b>Step 3:</b></font>
create a key here and give name of this key is : TasksItemsSelected
<font color="red"><b>Step 4:</b></font>
inside this key you need to give a value :
Windows.Copy; Windows.Paste; Windows.Delete;
<font color="red"><b>Step 5:</b></font>
Restart or Refresh your PC then your are done.

Newline Remover

<pre>
$lines=file('readerfile.txt');
$fp=fopen('writerfile.txt','w');
var_dump($lines);
foreach($lines as $line){
if($line=='\r\n' || $line=='\n' || $line=='\r' || $line==' ' || empty($line) || strlen(trim($line))==0){
echo '123';
}
else{
fwrite($fp,$line);
}
}
</pre>
watch the below picture:

<a href="http://ashique12009.files.wordpress.com/2011/07/newlineremover.jpg"><img class="alignnone size-full wp-image-75" title="newlineremover" src="http://ashique12009.files.wordpress.com/2011/07/newlineremover.jpg" alt="" width="450" height="129" /></a>

Remove index.php from Codeigniter url

<ol>
<li>Open <strong>config.php</strong> from <strong>system/application/config</strong> directory and replace
<strong>$config['index_page'] = “index.php”</strong> by <strong>$config['index_page'] = “”</strong></li>
<li>Create a <strong>“.htaccess”</strong> file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it:</li>
</ol>
===========================================

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

or

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

or do the below one:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /YOUR_PROJECT_FOLDER_NAME/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /inventshops/index.php/$1 [L]
</IfModule>

===========================================

3. In some case the default setting for <strong>uri_protocol</strong> does not work properly. To solve this problem just replace
<strong>$config['uri_protocol'] = “AUTO”</strong> by <strong>$config['uri_protocol'] = “REQUEST_URI”</strong> from <strong>system/application/config/config.php</strong>

And you are done !

if you fail to do this then please <strong>turn on or comment out</strong> mod_rewrite engine from <strong>httpd.conf</strong> file.

How to Enable mod_rewrite in Apache Server

<h3>How to Enable mod_rewrite in Apache Server</h3>
<ol>
<li>Before you begin this, <strong>please make sure you make a backup copy</strong> of the original file in case you make a mistake, this way you can always go back to the original configuration - always backup before you begin doing something like this.)</li>
<li>Find the <strong>httpd.conf</strong> file (usually you will find it in a folder called conf, config or something along those lines. In Fedora you can find it at <strong>/etc/httpd/</strong> directory.)</li>
<li>Inside the httpd.conf file find and uncomment the line <strong><em>LoadModule rewrite_module modules/mod_rewrite.so</em></strong> (remove the pound '#' sign from in front of the line - the # sign is for comments, by removing the # sign, you are uncommenting the line)</li>
<li>Also find the line <strong><em>ClearModuleList</em></strong> is uncommented then find and make sure that the line <strong><em>AddModule mod_rewrite.c</em></strong> is not commented out. (I didnt find these in Fedora, yet my mod_rewrite works great)</li>
<li>After you have made the changes and saved them, restart your httpd (apache) server for the changes to take affect. The easiest way to do this is to go to the shell command and type: <strong>/etc/init.d/httpd restart</strong> (this works for Fedora, might be different for other distributions!)</li>
<li>Done</li>
</ol>

schedule M.I.A.S wp-plugin

<pre>&lt;?php
/*
Plugin Name: Scheduled M.I.A.s
Plugin URI: http://blog.5ubliminal.com/topics/wordpress/plugins/
Description: Bring the left-for-dead &lt;code&gt;Missed Schedule&lt;/code&gt; posts back to life.
Version: 5.U.B
Author: 5ubliminal
Author URI: http://blog.5ubliminal.com/
Support URI: http://blog.5ubliminal.com/support/
*/
// -----------------------------------------------------------------------------
define('PLUGIN_SCHEDULEDMIAS_DELAY', 1); // Minutes .. change as you wish
define('PLUGIN_SCHEDULEDMIAS_OPTION', '_5ub_scheduled_mias'); // Option name
// -----------------------------------------------------------------------------
function _5ubliminal_Replacements_Deactivate(){
// Drop last update time on deactivate
delete_option(PLUGIN_SCHEDULEDMIAS_OPTION);
}
register_deactivation_hook(__FILE__, '_5ubliminal_Replacements_Deactivate');
// -----------------------------------------------------------------------------
function _5ubliminal_ScheduledMIAs_Init(){
// I disable internal cron jobs for post publishing completely
// ... Comment the line below to let Wordpress try do its job before we kick in
remove_action('publish_future_post', 'check_and_publish_future_post');
// Let's see if enough time passed from last publish
$last = get_option(PLUGIN_SCHEDULEDMIAS_OPTION, false);
if(($last !== false) &amp;&amp; ($last &gt; (time() - (PLUGIN_SCHEDULEDMIAS_DELAY * 60))))
return; // Too little time passed, bail here
// Update to the current time
update_option(PLUGIN_SCHEDULEDMIAS_OPTION, time());
// Global $wpdb object
global $wpdb;
// Find MIA post_IDs, try both LOCAL datetime and GMT datetime
$scheduledIDs = $wpdb-&gt;get_col(
"SELECT `ID` FROM `{$wpdb-&gt;posts}` ".
"WHERE ( ".
" ((`post_date` &gt; 0 )&amp;&amp; (`post_date` &lt;= CURRENT_TIMESTAMP())) OR ".
" ((`post_date_gmt` &gt; 0) &amp;&amp; (`post_date_gmt` &lt;= UTC_TIMESTAMP())) ".
") AND `post_status` = 'future'"
);
if(!count($scheduledIDs)) return; // None found ... bail
foreach($scheduledIDs as $scheduledID){
if(!$scheduledID) continue; // Just in case
// Publish each post_ID the Wordpress friendly way
wp_publish_post($scheduledID);
}
}
add_action('init', '_5ubliminal_ScheduledMIAs_Init', 0); // 0 Priority filter
// -----------------------------------------------------------------------------
?&gt;</pre>

jquery conflict fix by noconflict

     script start
var $s = jQuery.noConflict();          
$s(document).ready(function() {
    $s('#news-container').vTicker({
        speed: 500,
        pause: 3000,
        animation: 'fade',
        mousePause: true,
        showItems: 2
    });      
});
script close
    script start
        var $j = jQuery.noConflict();
        $j(document).ready(function() {
            $j('.sf-menu ul').superfish({
                delay:       1000,
                animation:   {opacity:'show',height:'show'},
                speed:       'medium',
                autoArrows:  false,
                dropShadows: 'medium'
            });
        });
    script close

Distinguish between safari and chrome by jquery

var userAgent = navigator.userAgent.toLowerCase();
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());

// Is this a version of Chrome?
if($.browser.chrome){
  userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
  userAgent = userAgent.substring(0,userAgent.indexOf('.'));
  $.browser.version = userAgent;
  // If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
  $.browser.safari = false;
}

// Is this a version of Safari?
if($.browser.safari){
  userAgent = userAgent.substring(userAgent.indexOf('safari/') +7);
  userAgent = userAgent.substring(0,userAgent.indexOf('.'));
  $.browser.version = userAgent;
}

make your web button more interactive by css

#button_id{
    background-color: #D9FDDC;
    background-image: -moz-linear-gradient(100% 100% 90deg, #D9FDDC, #E2FDE4);
    border: 1px solid #33CC66;
    border-radius: 5px 5px 5px 5px;
    color: #006633;
    cursor: pointer;
    line-height: 16px;
    padding: 3px 5px;
    text-decoration: none;
}

facebook social plugin

<a href="http://ashique12009.files.wordpress.com/2011/12/fbcom.jpg"><img src="http://ashique12009.files.wordpress.com/2011/12/fbcom.jpg" alt="" title="fbcom" width="450" height="202" class="alignnone size-full wp-image-98" /></a>

code below also:

Make a better css button

    background-color: #D9FDDC;
    background-image: -moz-linear-gradient(100% 100% 90deg, #D9FDDC, #E2FDE4);
    border: 1px solid #33CC66;
    border-radius: 5px 5px 5px 5px;
    color: #006633;
    cursor: pointer;
    line-height: 16px;
    padding: 3px 5px;
    text-decoration: none;

Disable update for your plugin

add_filter('CatPostWidget', 'dd_remove_update_nag');
function dd_remove_update_nag($value) {
unset($value-&gt;response[ plugin_basename(__FILE__) ]); return $value;
}

string cut function like excerpt in wordpress

function string_limit_words($string, $word_limit) {
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) &gt; $word_limit)
array_pop($words);
return implode(' ', $words);
}

call or invoke onclick event function by javascript

var elem = document.getElementById("image_id");
if (typeof elem.onclick == "function") {
elem.onclick.apply(elem);
}

css 2 lavel menu

div#menu2{
float: right;
    margin-top:30px;
    width: 555px;
}
#menu2 ul{
margin:0;
padding:0;
list-style-type:none;
/*padding-top:5px;*/
float:right;
}
#menu2 ul li{
float:left;
border-left:1px solid #787676;
padding-left:10px;
padding-right:10px;
padding: 15px 0 13px;
}
#menu2 ul li:first-child{
border-left:none;
}
#menu2 ul li a{
color:#787676;
font-size:21px;
text-decoration:none;
padding: 0 8px;
}
#menu2 ul ul {
    background-color: #FFFFFF;
    display: none;
    margin: 13px 0 0;
    position: absolute;
    width: 200px;
    z-index: 20;
}
#menu2 ul li:hover ul{
display:block;
}
#menu2 li:hover ul{
display:block;
}
#menu2 li li {
    border: medium none;
    margin: 0;
    padding: 10px 15px 0;
}
#menu2 li li a{
font-size:15px;
}
#menu2 li li a:hover{
color:#00CC00;
}

Submenu in joomla

get sub menu from backend in joomla
1. go to menu module
2. select your desire menu
3. in aprameters box check radio button YES to Always show submenu items
you are done.
but after that you have to manage css to arrange it.

detect safari only by jquery and css

var ua=navigator.userAgent;
if(ua.search("Safari") greater= 0 &amp;&amp; ua.search("Chrome") lessthan 0){
     do something here for your safari
}

add notepad to right-click menu in windows

download the below file and marge it to registry.
after that you should see the notepad in your right-click option.
http://www.mediafire.com/download.php?8zwsnegwmehz4ux

or you can make a notepad.reg file and put the following code and save it then marge it:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.txt]
"Content Type"="text/plain"
@="txtfile"
"PerceivedType"="text"
[HKEY_CLASSES_ROOT\.txt\OpenWithList]
[HKEY_CLASSES_ROOT\.txt\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
[HKEY_CLASSES_ROOT\.txt\shell]
[HKEY_CLASSES_ROOT\.txt\shell\open]
[HKEY_CLASSES_ROOT\.txt\shell\open\command]
@="notepad.exe %1"
[HKEY_CLASSES_ROOT\.txt\ShellNew]
"NullFile"=""

increase upload file size in phpmyadmin

<p>go to apache or php directory then find the php.ini file then find below word</p><p>and put whatever value you want like 5M,10M etc.</p><p>upload_max_filesize = ?</p>

Standalone template query support

include these below files to your custom template:
include_once('../../../wp-config.php');
include_once('../../../wp-load.php');
include_once('../../../wp-includes/wp-db.php');
then do query_posts() or any function that is related to WP :-)

jquery infinite scrolling in Php

html structure:
<div id="postswrapper">
<ul>
$args=array('category_name'=>'home_posts');
query_posts( $args );
while ( have_posts() ) : the_post();
echo '<li>';
if(has_post_thumbnail()):
<a href="the_permalink();">the_post_thumbnail('thumbnail');</a>
else:
<a href=" the_permalink();"><img src=" echo bloginfo('template_url');/images/noimage.jpg" alt="defaultimage" /></a>
endif;
echo '</li>';
endwhile;
// Reset Query
wp_reset_query();
</ul>
</div>
<div id="loadmoreajaxloader" style="display:none;"><center><img src="/images/ajaxloader.gif" /></center></div>
script:
<script type="text/javascript">
$(window).scroll(function()
{
if($(window).scrollTop() == $(document).height() - $(window).height())
{
$('div#loadmoreajaxloader').show();
$.ajax({
url: "bloginfo('template_url');/loadmore_template.php",
success: function(html){
if(html){
$("#postswrapper ul").append(html);
$('div#loadmoreajaxloader').hide();
}else{
$('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
}
}
});
}
});
</script>

how to add widget in wordpress

go to theme directory then open function.php file then find function function twentyeleven_widgets_init()
add following code inside it:
register_sidebar( array(
'name' => __( 'Main Sidebar', 'twentyeleven' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s">',
'after_widget' => "</aside>",
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
then call it by following code:
if(is_active_sidebar(f-1)):?>
dynamic_sidebar('f-1');
endif;

XML wrinting and reading with php

Watch out the below pictures for reading and writing data into xml file with php:

Retrieve feature image from specific page in wordpress

Watch out the below image to fix this problem:

jquery jcarousel slider

watch out the steps and set jcarousel for your wordpress site:
1.download jcarousel and jquery files.
there are 2 files link here:
http://www.mediafire.com/view/?29zva8khb9wki20
http://www.mediafire.com/view/?k8uk21x2xsxdcb0
2.set jcarousel and use it follow the picture:

Page link by slug [solved]

<?php echo get_page_link(get_page_by_path('contact-us')->ID); ?>

excerpt or read more text cut program

$content=get_the_content();
$words = explode(" ", $content);
$first = join(" ", array_slice($words, 0, 50));
echo $first;

article link [joomla]

index.php?option=com_content&amp;view=article&amp;id=58

just replace the id number with your article id number, it will bring you to your article.

[CRUD] insert, update and delete data in codeigniter in a smart way…

Insert:
in your controller:
$DataInArray=array(‘db_field_name’=>value,’db_field_name’=>value);
$insertStatus = $this->model_name->insertInToTable(‘table_name’, $DataInArray);
in your model:
public function insertInToTable($tableName, $insertedData){
$this->db->insert($tableName, $insertedData);
$is_inserted = $this->db->affected_rows() > 0;
if($is_inserted) return TRUE;
else return FALSE;
}
********************************************
Update:
in your controller:
$updateData=array(‘db_field_name1’=>value,’db_field_name2’=>value);
$this->Setup_Model->updateTable(‘db_field_id’,$this->input->post(‘match_id’),’table_name’,$updateData);
in your model:
public function updateTable($fieldId, $matchId, $tableName, $data){
$this->db->where($fieldId, $matchId);
$is_updated=$this->db->update($tableName, $data);
if($is_updated) return $is_updated;
else return $is_updated;
}
******************************************
Delete:
in your controller:
$id=assign your id value here for deletion;
$deleteStatus=$this->model_name->deleteTableData(‘field_id’,$id,’table_name’);
in your model:
public function deleteTableData($fieldId, $matchId, $tableName){
$this->db->delete($tableName, array($fieldId => $matchId));
$is_deleted = $this->db->affected_rows() > 0;
if($is_deleted) return TRUE;
else return FALSE;
}
******************************************

Switch PHP version in Ubuntu OS or Zorin OS

First check where is installed your PHP by the below command: $ which php See PHP version by below command: $ php -v As I've installed P...